pytask/taskapp/events/task.py
changeset 18 293692eb8f06
parent 14 f2623fb8041a
--- a/pytask/taskapp/events/task.py	Mon Feb 01 11:41:26 2010 +0530
+++ b/pytask/taskapp/events/task.py	Mon Feb 01 15:00:40 2010 +0530
@@ -1,5 +1,5 @@
 from datetime import datetime
-from pytask.taskapp.models import Profile, Task, Comment, Credit
+from pytask.taskapp.models import Profile, Task, Comment, Credit, Claim
 
 def publishTask(task):
     """ set the task status to open """
@@ -39,3 +39,25 @@
     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
+    claim.task = task
+    claim.user = user
+    claim.creation_datetime = datetime.now()
+    claim.save()
+    
+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"
+    task.save()