author | Nishanth Amuluru <nishanth@fossee.in> |
Wed, 05 Jan 2011 22:30:45 +0530 | |
changeset 219 | f04a1ec7a07f |
parent 155 | 52958289d81f |
permissions | -rw-r--r-- |
120 | 1 |
from django.http import Http404 |
2 |
from pytask.taskapp.models import Task, Map |
|
3 |
||
4 |
def getTask(tid): |
|
5 |
""" retreive the task from database. |
|
6 |
if the task has deps or subs, update its status correspondingly. |
|
7 |
""" |
|
8 |
||
9 |
try: |
|
10 |
task = Task.objects.get(id=tid) |
|
11 |
except Task.DoesNotExist: |
|
12 |
raise Http404 |
|
13 |
try: |
|
14 |
mapobj = Map.objects.get(main=task) |
|
15 |
except Map.DoesNotExist: |
|
16 |
mapobj = Map() |
|
17 |
mapobj.main = task |
|
18 |
mapobj.save() |
|
19 |
||
20 |
task_subs = mapobj.subs.all() |
|
21 |
||
22 |
if task.sub_type == "D": |
|
23 |
task.deps, task.subs = task_subs, [] |
|
24 |
elif task.sub_type == "S": |
|
25 |
task.subs, task.deps = task_subs, [] |
|
26 |
||
27 |
deps, subs = task.deps, task.subs |
|
28 |
if deps and task.status in ["OP", "LO"]: |
|
29 |
task.status = "OP" if all(map(lambda t:t.status=="CM",deps)) else "LO" |
|
155
52958289d81f
now if a task has subs, it will remain locked forever.
nishanth
parents:
120
diff
changeset
|
30 |
|
52958289d81f
now if a task has subs, it will remain locked forever.
nishanth
parents:
120
diff
changeset
|
31 |
## a task with subs will remain in "LO" and will be made "OP" only if all subs are removed. |
52958289d81f
now if a task has subs, it will remain locked forever.
nishanth
parents:
120
diff
changeset
|
32 |
if subs and task.status in ["OP", "LO"]: |
52958289d81f
now if a task has subs, it will remain locked forever.
nishanth
parents:
120
diff
changeset
|
33 |
task.status = "LO" |
120 | 34 |
|
35 |
task.save() |
|
36 |
return task |
|
37 |