merged.
authornishanth
Wed, 24 Feb 2010 19:18:59 +0530
changeset 84 3e75ed940408
parent 82 7c38ff64aee7 (diff)
parent 83 fd2e1bd7af82 (current diff)
child 85 9cf299c47990
merged.
--- a/taskapp/utilities/request.py	Wed Feb 24 19:17:28 2010 +0530
+++ b/taskapp/utilities/request.py	Wed Feb 24 19:18:59 2010 +0530
@@ -1,7 +1,7 @@
 from pytask.taskapp.models import Request
 from datetime import datetime
 
-def create_request(to,by,role,task=None,assigned_user=None):
+def create_request(to,by,role,task=None,assigned_user=None,pynts=0):
     """
     creates an unreplied request, based on the passed arguments
         to - a list of users to which the notification is to be sent
@@ -20,24 +20,21 @@
         req.task = task
     if assigned_user:
         req.assigned_user = assigned_user
+    req.pynts = pynts
     req.save()
 
-def reply_to_request(request_id, reply):
+def reply_to_request(request_obj, reply):
     """
     makes a request replied with the given reply.
     arguments:
-        request_id - a number denoting the id of the Request object
+        request_obj - Request object for which change is intended
         reply - a boolean value to be given as reply (True/False)
     """
-    try:
-        request = Request.objects.get(id = request_id)
-    except Request.DoesNotExist:
-        return False #No such request exist
-    if not request.replied:
-        request.reply = reply
-        request.replied = True
-        request.read = True
-        request.reply_date = datetime.now()
-        request.save()
+    if not request_obj.replied:
+        request_obj.reply = reply
+        request_obj.replied = True
+        request_obj.read = True
+        request_obj.reply_date = datetime.now()
+        request_obj.save()
         return True #Reply has been added successfully
     return False #Already replied