diff options
author | nishanth | 2010-02-24 10:42:46 +0530 |
---|---|---|
committer | nishanth | 2010-02-24 10:42:46 +0530 |
commit | fde938bb05d0444568b044487d6865b2dfc7608c (patch) | |
tree | 64413d3b636c27fcf251742e6a822550c68e8bc7 | |
parent | f9f85f5025ecf885ec373cd90061dc7eba848927 (diff) | |
download | pytask-fde938bb05d0444568b044487d6865b2dfc7608c.tar.gz pytask-fde938bb05d0444568b044487d6865b2dfc7608c.tar.bz2 pytask-fde938bb05d0444568b044487d6865b2dfc7608c.zip |
added events in task.py for adding subtask and dependencies
-rw-r--r-- | taskapp/events/task.py | 35 | ||||
-rw-r--r-- | taskapp/models.py | 4 |
2 files changed, 24 insertions, 15 deletions
diff --git a/taskapp/events/task.py b/taskapp/events/task.py index 4fcf90f..3712dbd 100644 --- a/taskapp/events/task.py +++ b/taskapp/events/task.py @@ -15,7 +15,7 @@ def publishTask(task): def addSubTask(main_task, sub_task): """ add the task to subs attribute of the task and update its status. - sub task can be added only if a task is in UP/OP/LO/Cd state. + sub task can be added only if a task is in UP/OP/LO state. """ ## Shall modify after talking to pr about subtasks @@ -70,21 +70,12 @@ def createTask(title,desc,created_by,credits): task.save() return task -def addSubTask(main_task, sub_task): - """ add sub_task to subs list of main_task """ - - main_task.subs.add(sub_task) - main_task.status = "LO" - main_task.save() - return main_task - def addClaim(task, message, user): """ add claim data to the database if it does not exist and also update the claimed users field of the task. """ task.claimed_users.add(user) - task.status = "CL" task.save() claim = Claim() claim.message = message @@ -96,8 +87,10 @@ def addClaim(task, message, user): def assignTask(task, user): """ check for the status of task and assign it to the particular user """ - task.assigned_users.add(user) - task.status = "AS" + if task.status in ['OP', 'WR']: + task.assigned_users.add(user) + task.claimed_users.remove(user) + task.status = "WR" task.save() def getTask(tid): @@ -116,3 +109,21 @@ def getTask(tid): task.save() return task + +def updateTask(task, title=None, desc=None, credits=None, tags_field=None): + """ update the property accordingly. + while updating title, check for uniqueness of title. + return None if any error. + """ + + if title: + try: + task.title = title + task.save() + except IntegrityError: + return None + if desc:task.desc = desc + if credits:task.credits = credits + if tags_field:task.tags_field = tags_field + task.save() + return task diff --git a/taskapp/models.py b/taskapp/models.py index eb5130a..62458ac 100644 --- a/taskapp/models.py +++ b/taskapp/models.py @@ -18,9 +18,7 @@ STATUS_CHOICES = ( ("UP", "Unpublished"), ("OP", "Open"), ("LO", "Locked"), - ("CL", "Claimed"), - ("AS", "Assigned"), - ("RE", "Reopened"), + ("WR", "Working"), ("CD", "Closed"), ("DL", "Deleted"), ("CM", "Completed")) |