summaryrefslogtreecommitdiff
path: root/taskapp/events/task.py
diff options
context:
space:
mode:
Diffstat (limited to 'taskapp/events/task.py')
-rw-r--r--taskapp/events/task.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/taskapp/events/task.py b/taskapp/events/task.py
index 4f76f8e..4fcf90f 100644
--- a/taskapp/events/task.py
+++ b/taskapp/events/task.py
@@ -99,3 +99,20 @@ def assignTask(task, user):
task.assigned_users.add(user)
task.status = "AS"
task.save()
+
+def getTask(tid):
+ """ retreive the task from database.
+ if the task has deps or subs, update its status correspondingly.
+ """
+
+ task = Task.objects.get(id=tid)
+ deps = task.deps.all()
+ subs = task.subs.all()
+
+ if deps and task.status in ["OP", "LO"]:
+ task.status = "OP" if all(map(lambda t:t.status=="CM",deps)) else "LO"
+ if subs and task.status in ["OP", "LO", "CM"]:
+ task.status = "CM" if all(map(lambda t:t.status=="CM",subs)) else "LO"
+
+ task.save()
+ return task