summaryrefslogtreecommitdiff
path: root/taskapp/utilities
diff options
context:
space:
mode:
authoranoop2010-02-24 16:49:30 +0530
committeranoop2010-02-24 16:49:30 +0530
commitafef2d96978cd0afa2e3398e30e98dcaff6c2166 (patch)
treed5c632b720a18d325ee2a2265cb49f8f8233bdb0 /taskapp/utilities
parent4ee56fb25760237577fb10df8f64843a76075a71 (diff)
downloadpytask-afef2d96978cd0afa2e3398e30e98dcaff6c2166.tar.gz
pytask-afef2d96978cd0afa2e3398e30e98dcaff6c2166.tar.bz2
pytask-afef2d96978cd0afa2e3398e30e98dcaff6c2166.zip
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
Diffstat (limited to 'taskapp/utilities')
-rw-r--r--taskapp/utilities/notification.py28
-rw-r--r--taskapp/utilities/request.py28
2 files changed, 52 insertions, 4 deletions
diff --git a/taskapp/utilities/notification.py b/taskapp/utilities/notification.py
index 816e8bf..5f72540 100644
--- a/taskapp/utilities/notification.py
+++ b/taskapp/utilities/notification.py
@@ -14,3 +14,31 @@ def create_notification(to,subject,message):
notification.sub = subject
notification.message = message
notification.save()
+
+def mark_notification_read(notification_id):
+ """
+ makes a notification identified by the notification_id read.
+ arguments:
+ notification_id - a number denoting the id of the Notification object
+ """
+ try:
+ notification = Notification.objects.get(id = notification_id)
+ except Notification.DoesNotExist:
+ return False
+ notification.is_read = True
+ notification.save()
+ return True
+
+def delete_notification(notification_id):
+ """
+ deletes a notification identified by the notification_id.
+ arguments:
+ notification_id - a number denoting the id of the Notification object
+ """
+ try:
+ notification = Notification.objects.get(id = notification_id)
+ except Notification.DoesNotExist:
+ return False
+ notification.deleted = True
+ notification.save()
+ return True
diff --git a/taskapp/utilities/request.py b/taskapp/utilities/request.py
index 41370f8..85bd8e6 100644
--- a/taskapp/utilities/request.py
+++ b/taskapp/utilities/request.py
@@ -7,8 +7,8 @@ def create_request(to,by,role,task=None,assigned_user=None):
to - a list of users to which the notification is to be sent
by - sender of request
role - a two character field which represents the role requested
- task - a requesting task (useful for sending admins a request to give Pynts to the user, assigning a user to a task)
- assigned_user - user to whom the Pynts/Task is assigned to(useful for sending admins a request to give Pynts to the user, assigning a user to a task)
+ task - a requesting task (useful for sending admins a request to give Pynts to the user)
+ assigned_user - user to whom the Pynts/Task is assigned to(useful for sending admins a request to give Pynts to the user)
"""
req = Request(creation_date=datetime.now())
req.by = by
@@ -16,8 +16,28 @@ def create_request(to,by,role,task=None,assigned_user=None):
req.save()
req.to = to
req.role = role
- if task not None:
+ if task is not None:
req.task = task
- if assigned_user not None:
+ if assigned_user is not None:
req.assigned_user = assigned_user
req.save()
+
+def reply_to_request(request_id, reply):
+ """
+ makes a request replied with the given reply.
+ arguments:
+ request_id - a number denoting the id of the Request object
+ 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 request.replied is not True:
+ request.reply = reply
+ request.replied = True
+ request.read = True
+ request.reply_date = datetime.now()
+ request.save()
+ return True #Reply has been added successfully
+ return False #Already replied