diff options
author | nishanth | 2010-02-25 03:47:23 +0530 |
---|---|---|
committer | nishanth | 2010-02-25 03:47:23 +0530 |
commit | 1ad94f0330dc47801a129299122ea8d97d4b1623 (patch) | |
tree | 9016407db082f5db061648ae00294872d3f2469e /taskapp/events | |
parent | a4dc314c81b55b37e0d7cb251890cef53d95cc80 (diff) | |
download | pytask-1ad94f0330dc47801a129299122ea8d97d4b1623.tar.gz pytask-1ad94f0330dc47801a129299122ea8d97d4b1623.tar.bz2 pytask-1ad94f0330dc47801a129299122ea8d97d4b1623.zip |
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
Diffstat (limited to 'taskapp/events')
-rw-r--r-- | taskapp/events/task.py | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/taskapp/events/task.py b/taskapp/events/task.py index 335b645..727b04e 100644 --- a/taskapp/events/task.py +++ b/taskapp/events/task.py @@ -1,12 +1,15 @@ from datetime import datetime -from pytask.taskapp.models import Profile, Task, Comment, Credit, Claim +from pytask.taskapp.models import Profile, Task, Comment, Credit, Claim, Map def publishTask(task): """ set the task status to open """ - - sub_tasks = task.subs.all() - dependencies = task.deps.all() - if sub_tasks or any(map(lambda t:t.status!="CM",dependencies)): + + if task.sub_type == 'D': + deps, subs = task.map_subs.all(), [] + else: + subs, deps = task.map_subs.all(), [] + + if subs or any(map(lambda t:t.status!="CM",deps)): task.status = "LO" else: task.status = "OP" @@ -20,8 +23,20 @@ def addSubTask(main_task, sub_task): ## Shall modify after talking to pr about subtasks ## I think i might even remove the concept of subtasks - main_task.subs.add(sub_task) - sub_tasks = main_task.subs.all() + + main_task.sub_type = "S" + main_task.save() + + try: + mapobj = Map.objects.get(main=main_task) + except Map.DoesNotExist: + mapobj = Map() + mapobj.main = main_task + mapobj.save() + mapobj.subs.add(sub_task) + mapobj.save() + + sub_tasks = getTask(main_task.id).subs if main_task.status == "OP": if any(map(lambda t:t.status!="CM",sub_tasks)): main_task.status = "LO" @@ -36,8 +51,21 @@ def addDep(main_task, dependency): And also if the task doesn't have any subs. """ - main_task.deps.add(dependency) - deps = main_task.deps.all() + main_task.sub_type = "D" + main_task.save() + + try: + mapobj = Map.objects.get(main=main_task) + except Map.DoesNotExist: + mapobj = Map() + mapobj.main = main_task + mapobj.save() + + mapobj.subs.add(dependency) + mapobj.save() + + deps = getTask(main_task.id).deps + if main_task.status in ["OP", "LO"]: if all(map(lambda t:t.status=="CM",deps)): main_task.status = "OP" @@ -99,9 +127,21 @@ def getTask(tid): """ task = Task.objects.get(id=tid) - deps = task.deps.all() - subs = task.subs.all() + try: + mapobj = Map.objects.get(main=task) + except Map.DoesNotExist: + mapobj = Map() + mapobj.main = task + mapobj.save() + + task_subs = mapobj.subs.all() + + if task.sub_type == "D": + task.deps, task.subs = task_subs, [] + elif task.sub_type == "S": + task.subs, task.deps = task_subs, [] + deps, subs = task.deps, task.subs 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"]: |