author | anoop |
Wed, 24 Feb 2010 19:11:43 +0530 | |
changeset 82 | 7c38ff64aee7 |
parent 81 | cade14d25a58 |
child 87 | f0a3d6612462 |
permissions | -rw-r--r-- |
58 | 1 |
from pytask.taskapp.models import Request |
2 |
from datetime import datetime |
|
3 |
||
81 | 4 |
def create_request(to,by,role,task=None,assigned_user=None,pynts=0): |
58 | 5 |
""" |
6 |
creates an unreplied request, based on the passed arguments |
|
7 |
to - a list of users to which the notification is to be sent |
|
8 |
by - sender of request |
|
9 |
role - a two character field which represents the role requested |
|
78
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
10 |
task - a requesting task (useful for sending admins a request to give Pynts to the user) |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
11 |
assigned_user - user to whom the Pynts/Task is assigned to(useful for sending admins a request to give Pynts to the user) |
58 | 12 |
""" |
13 |
req = Request(creation_date=datetime.now()) |
|
14 |
req.by = by |
|
15 |
req.reply_date = datetime(1970,01,01) |
|
16 |
req.save() |
|
17 |
req.to = to |
|
18 |
req.role = role |
|
80 | 19 |
if task: |
71
801cf8fca53a
made change to the request model and corresponding create_request utility.
anoop
parents:
58
diff
changeset
|
20 |
req.task = task |
80 | 21 |
if assigned_user: |
71
801cf8fca53a
made change to the request model and corresponding create_request utility.
anoop
parents:
58
diff
changeset
|
22 |
req.assigned_user = assigned_user |
81 | 23 |
req.pynts = pynts |
58 | 24 |
req.save() |
78
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
25 |
|
82
7c38ff64aee7
changed the method reply_to_request to accept request object instead of request id.
anoop
parents:
81
diff
changeset
|
26 |
def reply_to_request(request_obj, reply): |
78
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
27 |
""" |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
28 |
makes a request replied with the given reply. |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
29 |
arguments: |
82
7c38ff64aee7
changed the method reply_to_request to accept request object instead of request id.
anoop
parents:
81
diff
changeset
|
30 |
request_obj - Request object for which change is intended |
78
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
31 |
reply - a boolean value to be given as reply (True/False) |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
32 |
""" |
82
7c38ff64aee7
changed the method reply_to_request to accept request object instead of request id.
anoop
parents:
81
diff
changeset
|
33 |
if not request_obj.replied: |
7c38ff64aee7
changed the method reply_to_request to accept request object instead of request id.
anoop
parents:
81
diff
changeset
|
34 |
request_obj.reply = reply |
7c38ff64aee7
changed the method reply_to_request to accept request object instead of request id.
anoop
parents:
81
diff
changeset
|
35 |
request_obj.replied = True |
7c38ff64aee7
changed the method reply_to_request to accept request object instead of request id.
anoop
parents:
81
diff
changeset
|
36 |
request_obj.read = True |
7c38ff64aee7
changed the method reply_to_request to accept request object instead of request id.
anoop
parents:
81
diff
changeset
|
37 |
request_obj.reply_date = datetime.now() |
7c38ff64aee7
changed the method reply_to_request to accept request object instead of request id.
anoop
parents:
81
diff
changeset
|
38 |
request_obj.save() |
78
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
39 |
return True #Reply has been added successfully |
c5bcafccc135
added utilities reply_to_request, mark_notification_read, delete_notification and made change to create_request utility.
anoop
parents:
71
diff
changeset
|
40 |
return False #Already replied |