From 7799bae123341ce81fe3f7525fbe593d674af880 Mon Sep 17 00:00:00 2001 From: paopow Date: Wed, 26 Jun 2019 15:47:07 -0400 Subject: [PATCH] Fix the todos dashboard bugs (#535) * Make it possible to log time for pending tasks * Only mark a task as not new if there is non-templated task * Fix lint errors * Fix lint errors --- .../static/orchestra/common/js/orchestra.services.es6.js | 6 +++--- .../timing/timecard/task-select/task-select.html | 2 +- orchestra/utils/task_lifecycle.py | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/orchestra/static/orchestra/common/js/orchestra.services.es6.js b/orchestra/static/orchestra/common/js/orchestra.services.es6.js index ce838ddce..0cbdb00cc 100644 --- a/orchestra/static/orchestra/common/js/orchestra.services.es6.js +++ b/orchestra/static/orchestra/common/js/orchestra.services.es6.js @@ -112,10 +112,10 @@ export function orchestraTasks ($http) { pendingTasks: function () { return this.allTasks().filter(task => pendingTask(task)) }, pausedTasks: function () { return this.allTasks().filter(task => pausedTask(task)) }, completedTasks: function () { return this.allTasks().filter(task => task.state === 'complete') }, - activeAndRecentTasks: function (numRecent) { - // Return all active tasks, as well as `numRecent` of the most + activePendingAndRecentTasks: function (numRecent) { + // Return all active tasks, pending tasks, as well as `numRecent` of the most // recently completed tasks. - var tasks = this.activeTasks() + var tasks = this.activeTasks().concat(this.pendingTasks()) return tasks.concat(this.completedTasks().slice(0, numRecent)) }, getDescription: function (task) { diff --git a/orchestra/static/orchestra/timing/timecard/task-select/task-select.html b/orchestra/static/orchestra/timing/timecard/task-select/task-select.html index 194b1c804..f416cdef1 100644 --- a/orchestra/static/orchestra/timing/timecard/task-select/task-select.html +++ b/orchestra/static/orchestra/timing/timecard/task-select/task-select.html @@ -3,7 +3,7 @@ - + diff --git a/orchestra/utils/task_lifecycle.py b/orchestra/utils/task_lifecycle.py index 70cf938b0..0f54e8bee 100644 --- a/orchestra/utils/task_lifecycle.py +++ b/orchestra/utils/task_lifecycle.py @@ -588,7 +588,9 @@ def tasks_assigned_to_worker(worker): 'start_by_datetime': start_str, 'due_datetime': due_str } - num_todos = task_assignment.task.todos.count() + num_non_template_todos = ( + task_assignment.task.todos + .filter(template=None).count()) # If a task has no todos (complete or incomplete) # assigned to it, then by default the task would be # marked as pending. When a task is first created and @@ -605,7 +607,9 @@ def tasks_assigned_to_worker(worker): or next_todo.start_by_datetime <= time_now ) ) - should_be_active = (num_todos == 0) or task_started + should_be_active = ( + (num_non_template_todos == 0) + or task_started) tasks_assigned.append({ 'id': task_assignment.task.id, 'assignment_id': task_assignment.id,