added events in task.py for adding subtask and dependencies
authornishanth
Wed, 24 Feb 2010 10:42:46 +0530
changeset 63 1fc027bf99ee
parent 62 db103856505e
child 64 e743fe1f0f99
added events in task.py for adding subtask and dependencies
taskapp/events/task.py
taskapp/models.py
--- a/taskapp/events/task.py	Tue Feb 23 20:40:55 2010 +0530
+++ b/taskapp/events/task.py	Wed Feb 24 10:42:46 2010 +0530
@@ -15,7 +15,7 @@
 
 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 @@
     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 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 @@
 
     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
--- a/taskapp/models.py	Tue Feb 23 20:40:55 2010 +0530
+++ b/taskapp/models.py	Wed Feb 24 10:42:46 2010 +0530
@@ -18,9 +18,7 @@
     ("UP", "Unpublished"),
     ("OP", "Open"),
     ("LO", "Locked"),
-    ("CL", "Claimed"),
-    ("AS", "Assigned"),
-    ("RE", "Reopened"),
+    ("WR", "Working"),
     ("CD", "Closed"),
     ("DL", "Deleted"),
     ("CM", "Completed"))