25 receiving_user = request_obj.receiving_user |
25 receiving_user = request_obj.receiving_user |
26 requested_by = request_obj.sent_by |
26 requested_by = request_obj.sent_by |
27 for a_mentor in task.mentors.all(): |
27 for a_mentor in task.mentors.all(): |
28 if reply: |
28 if reply: |
29 addCredits(task, request_obj.sent_by, request_obj.receiving_user, pynts) |
29 addCredits(task, request_obj.sent_by, request_obj.receiving_user, pynts) |
30 create_notification(request_obj.role, a_mentor, replied_by, True, task, receiving_user, pynts, requested_by) |
30 create_notification(request_obj.role, a_mentor, replied_by, True, task, request_obj.remarks, requested_by, receiving_user, pynts) |
31 else: |
31 else: |
32 create_notification(request_obj.role, a_mentor, replied_by, False, task, receiving_user, pynts, requested_by, request_obj.remarks) |
32 create_notification(request_obj.role, a_mentor, replied_by, False, task, request_obj.remarks, requested_by, receiving_user, pynts) |
33 |
33 |
34 elif request_obj.role == "MT": |
34 elif request_obj.role == "MT": |
35 ## add him as a mentor to the task |
35 task = request_obj.task |
|
36 requested_by = request_obj.sent_by |
36 if reply: |
37 if reply: |
37 ## check for the current rights of request_obj.sent_by |
38 ## tell the replied user that he is mentor for this task and give him learn more link |
38 ## what if he is no more a mentor to the task |
39 create_notification("NT", request_obj.replied_by, task=task) |
39 addMentor(request_obj.task, request_obj.replied_by) |
40 |
40 ## pass on notification of request_obj.sent_by |
41 ## alert all the mentors including who made request and all assigned users |
|
42 for a_mentor in task.mentors.all(): |
|
43 create_notification(request_obj.role, a_mentor, replied_by, True, task, request_obj.remarks, requested_by) |
|
44 for a_user in task.assigned_users.all(): |
|
45 create_notification(request_obj.role, a_user, replied_by, True, task, request_obj.remarks, requested_by) |
|
46 |
|
47 addMentor(task, request_obj.replied_by) |
41 else: |
48 else: |
42 print "request for mentor rejected" |
49 ## tell the requested user that his request was rejected due to these reasons. |
43 ## pass on notification to request_obj.sent_by |
50 create_notification(request_obj.role, requested_by, replied_by, False, task, request_obj.remarks, requested_by) |
44 |
51 |
45 elif request_obj.role in ["AD", "MG", "DV"]: |
52 elif request_obj.role in ["AD", "MG", "DV"]: |
46 if reply: |
53 if reply: |
47 ## make him the role |
54 ## make him the role |
48 ## here we check for rights just in case to be fine with demoted users. we change only the user who made request has that rights. |
55 ## here we check for rights just in case to be fine with demoted users. we change only the user who made request has that rights. |