author | Madhusudan.C.S <madhusudancs@gmail.com> |
Thu, 06 Jan 2011 19:07:04 +0530 | |
branch | buildout |
changeset 227 | 3c8f3b0e5b00 |
permissions | -rw-r--r-- |
227
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
from django.http import Http404 |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
from pytask.taskapp.models import Task, Map |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
4 |
def getTask(tid): |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
5 |
""" retreive the task from database. |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
6 |
if the task has deps or subs, update its status correspondingly. |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
""" |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
8 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
9 |
try: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
10 |
task = Task.objects.get(id=tid) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
11 |
except Task.DoesNotExist: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
12 |
raise Http404 |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
13 |
try: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
14 |
mapobj = Map.objects.get(main=task) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
15 |
except Map.DoesNotExist: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
16 |
mapobj = Map() |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
17 |
mapobj.main = task |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
18 |
mapobj.save() |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
19 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
20 |
task_subs = mapobj.subs.all() |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
21 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
22 |
if task.sub_type == "D": |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
23 |
task.deps, task.subs = task_subs, [] |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
24 |
elif task.sub_type == "S": |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
25 |
task.subs, task.deps = task_subs, [] |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
26 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
27 |
deps, subs = task.deps, task.subs |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
28 |
if deps and task.status in ["OP", "LO"]: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
29 |
task.status = "OP" if all(map(lambda t:t.status=="CM",deps)) else "LO" |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
30 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
31 |
## a task with subs will remain in "LO" and will be made "OP" only if all subs are removed. |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
32 |
if subs and task.status in ["OP", "LO"]: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
33 |
task.status = "LO" |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
34 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
35 |
task.save() |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
36 |
return task |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
37 |