taskapp/events/task.py
changeset 55 ca2486e29178
parent 54 943d682aefdd
child 63 1fc027bf99ee
--- a/taskapp/events/task.py	Tue Feb 23 11:52:22 2010 +0530
+++ b/taskapp/events/task.py	Tue Feb 23 12:16:28 2010 +0530
@@ -99,3 +99,20 @@
     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