author | nishanth |
Fri, 26 Feb 2010 00:17:54 +0530 | |
changeset 105 | 091b044a3bf4 |
parent 100 | 2275886511df |
child 107 | 4903b4973fc8 |
permissions | -rw-r--r-- |
100 | 1 |
from datetime import datetime |
105
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
100
diff
changeset
|
2 |
from pytask.taskapp.events.task import addCredits, addMentor |
100 | 3 |
|
4 |
def reply_to_request(request_obj, reply, replied_by): |
|
5 |
""" |
|
6 |
makes a request replied with the given reply. |
|
7 |
arguments: |
|
8 |
request_obj - Request object for which change is intended |
|
9 |
reply - a boolean value to be given as reply (True/False) |
|
10 |
replied_by - the user object who replies to the request |
|
11 |
""" |
|
12 |
if not request_obj.is_replied: |
|
13 |
request_obj.reply = reply |
|
14 |
request_obj.is_replied = True |
|
15 |
request_obj.reply_date = datetime.now() |
|
16 |
request_obj.replied_by = replied_by |
|
17 |
request_obj.save() |
|
18 |
||
19 |
if request_obj.role == "PY": |
|
20 |
if reply: |
|
21 |
addCredits(request_obj.task, request_obj.sent_by, request_obj.receiving_user, request_obj.pynts) |
|
22 |
print "send yes notifications appropriately" |
|
23 |
else: |
|
24 |
print "send a no notificvaton" |
|
25 |
elif request_obj.role == "MT": |
|
26 |
## add him as a mentor to the task |
|
105
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
100
diff
changeset
|
27 |
if reply: |
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
100
diff
changeset
|
28 |
addMentor(request_obj.task, request_obj.replied_by) |
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
100
diff
changeset
|
29 |
## pass on notification of request_obj.sent_by |
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
100
diff
changeset
|
30 |
else: |
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
100
diff
changeset
|
31 |
print "request for mentor rejected" |
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
100
diff
changeset
|
32 |
## pass on notification to request_obj.sent_by |
091b044a3bf4
now adding mentor for a task happens through request. notifications still pending though
nishanth
parents:
100
diff
changeset
|
33 |
|
100 | 34 |
elif request_obj.role in ["AD", "MG", "DV"]: |
35 |
if reply: |
|
36 |
pass |
|
37 |
## make him the role |
|
38 |
## changeRole(role=request_obj.role, made_by=request_obj.sent_by) |
|
39 |
else: |
|
40 |
## notify request_obj.sent_by that it has been rejected |
|
41 |
pass |
|
42 |
return True #Reply has been added successfully |
|
43 |
return False #Already replied |