author | Madhusudan.C.S <madhusudancs@gmail.com> |
Thu, 06 Jan 2011 19:07:04 +0530 | |
branch | buildout |
changeset 227 | 3c8f3b0e5b00 |
permissions | -rw-r--r-- |
227
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
from datetime import datetime |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
from pytask.taskapp.models import Profile |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
from pytask.taskapp.events.task import addMentor |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
4 |
from pytask.taskapp.events.user import changeRole |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
5 |
from pytask.taskapp.utilities.notification import create_notification |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
6 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
def reply_to_request(request_obj, reply, replied_by): |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
8 |
""" |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
9 |
makes a request replied with the given reply. |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
10 |
arguments: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
11 |
request_obj - Request object for which change is intended |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
12 |
reply - a boolean value to be given as reply (True/False) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
13 |
replied_by - the user object who replies to the request |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
14 |
""" |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
15 |
if not request_obj.is_replied: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
16 |
request_obj.reply = reply |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
17 |
request_obj.is_replied = True |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
18 |
request_obj.reply_date = datetime.now() |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
19 |
request_obj.replied_by = replied_by |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
20 |
request_obj.save() |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
21 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
22 |
if request_obj.role == "PY": |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
23 |
## note that we are not doing any check. we make requests invalid when an event like closing task happens. |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
24 |
task = request_obj.task |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
25 |
pynts = request_obj.pynts |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
26 |
receiving_user = request_obj.receiving_user |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
27 |
requested_by = request_obj.sent_by |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
28 |
create_notification(request_obj.role, receiving_user, replied_by, reply, task, request_obj.remarks, requested_by, receiving_user, pynts) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
29 |
if receiving_user != requested_by: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
30 |
create_notification(request_obj.role, requested_by, replied_by, reply, task, request_obj.remarks, requested_by, receiving_user, pynts) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
31 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
32 |
elif request_obj.role == "MT": |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
33 |
task = request_obj.task |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
34 |
requested_by = request_obj.sent_by |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
35 |
if reply: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
36 |
## tell the replied user that he is mentor for this task and give him learn more link |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
37 |
create_notification("NT", request_obj.replied_by, task=task) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
38 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
39 |
## now check if there are such similar requests and mark them as invalid |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
40 |
## they cannot be of type PY and so we can use the replied_by to get requests |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
41 |
pending_requests = replied_by.request_sent_to.filter(is_valid=True, is_replied=False, role="MT",task=task) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
42 |
for req in pending_requests: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
43 |
create_notification("MT", req.sent_by, replied_by, False, task=req.task, remarks = "User has already accepted one such request and is a mentor.", requested_by = req.sent_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
44 |
req.is_valid = False |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
45 |
req.save() |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
46 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
47 |
## alert all the mentors including who made request and all assigned users |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
48 |
for a_mentor in task.mentors.all(): |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
49 |
create_notification(request_obj.role, a_mentor, replied_by, True, task, request_obj.remarks, requested_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
50 |
for a_user in task.assigned_users.all(): |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
51 |
create_notification(request_obj.role, a_user, replied_by, True, task, request_obj.remarks, requested_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
52 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
53 |
addMentor(task, request_obj.replied_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
54 |
else: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
55 |
## tell the requested user that his request was rejected due to these reasons. |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
56 |
create_notification(request_obj.role, requested_by, replied_by, False, task, request_obj.remarks, requested_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
57 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
58 |
elif request_obj.role == "DV": |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
59 |
if reply: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
60 |
## here we look for requests that are similar => requesting for DV and make them invalid |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
61 |
## also we drop a notification to user who made request |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
62 |
pending_requests = request_obj.replied_by.request_sent_to.filter(is_valid=True,is_replied=False,role="DV") |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
63 |
for req in pending_requests: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
64 |
req.is_valid = False |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
65 |
req.save() |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
66 |
create_notification(role = req.role, sent_to = req.sent_by, sent_from = replied_by, reply = False, \ |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
67 |
remarks = "User has accepted a similar request and has rights same or higher privileged than the request", \ |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
68 |
requested_by = req.sent_by ) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
69 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
70 |
## tell only the user who made him a DV |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
71 |
## drop a welcome message to that fucker |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
72 |
create_notification(request_obj.role, request_obj.sent_by, request_obj.replied_by, reply, requested_by=request_obj.sent_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
73 |
create_notification("ND", request_obj.replied_by, requested_by=request_obj.sent_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
74 |
changeRole(role=request_obj.role, user=request_obj.replied_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
75 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
76 |
else: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
77 |
create_notification(request_obj.role, request_obj.sent_by, request_obj.replied_by, reply, remarks=request_obj.remarks, requested_by=request_obj.sent_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
78 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
79 |
elif request_obj.role == "MG": |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
80 |
if reply: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
81 |
## tell all the MG and AD |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
82 |
alerting_users = Profile.objects.filter(user__is_active=True).exclude(rights="CT").exclude(rights="DV") |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
83 |
for a_profile in alerting_users: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
84 |
create_notification(request_obj.role, a_profile.user, request_obj.replied_by, reply, requested_by=request_obj.sent_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
85 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
86 |
## here we look for requests that less or similar => requesting for DV or MG and make them invalid |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
87 |
## also we drop a notification to user who made request |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
88 |
active_requests = request_obj.replied_by.request_sent_to.filter(is_valid=True,is_replied=False) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
89 |
pending_requests = active_requests.filter(role="DV") | active_requests.filter(role="MG") |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
90 |
for req in pending_requests: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
91 |
req.is_valid = False |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
92 |
req.save() |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
93 |
create_notification(role = req.role, sent_to = req.sent_by, sent_from = replied_by, reply = False, \ |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
94 |
remarks = "User has accepted a similar request and has rights same or higher privileged than the request", \ |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
95 |
requested_by = req.sent_by ) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
96 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
97 |
## drop a welcome message to that fucker |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
98 |
create_notification("NG", request_obj.replied_by, requested_by=request_obj.sent_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
99 |
changeRole(role=request_obj.role, user=request_obj.replied_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
100 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
101 |
else: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
102 |
create_notification(request_obj.role, request_obj.sent_by, request_obj.replied_by, reply, remarks=request_obj.remarks, requested_by=request_obj.sent_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
103 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
104 |
elif request_obj.role == "AD": |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
105 |
if reply: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
106 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
107 |
## here we look for requests that less or similar => requesting for DV or MG or AD and make them invalid |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
108 |
## also we drop a notification to user who made request |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
109 |
active_requests = request_obj.replied_by.request_sent_to.filter(is_valid=True,is_replied=False) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
110 |
pending_requests = active_requests.filter(role="DV") | active_requests.filter(role="MG") | active_requests.filter(role="AD") |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
111 |
for req in pending_requests: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
112 |
req.is_valid = False |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
113 |
req.save() |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
114 |
create_notification(role = req.role, sent_to = req.sent_by, sent_from = replied_by, reply = False, \ |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
115 |
remarks = "User has accepted a similar request and has rights same or higher privileged than the request", \ |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
116 |
requested_by = req.sent_by ) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
117 |
## tell all the AD |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
118 |
alerting_users = Profile.objects.filter(user__is_active=True).filter(rights="AD") |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
119 |
for a_profile in alerting_users: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
120 |
create_notification(request_obj.role, a_profile.user, request_obj.replied_by, reply, requested_by=request_obj.sent_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
121 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
122 |
## drop a welcome message to that fucker |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
123 |
create_notification("NA", request_obj.replied_by, requested_by=request_obj.sent_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
124 |
changeRole(role=request_obj.role, user=request_obj.replied_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
125 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
126 |
else: |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
127 |
create_notification(request_obj.role, request_obj.sent_by, request_obj.replied_by, reply, remarks=request_obj.remarks, requested_by=request_obj.sent_by) |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
128 |
|
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
129 |
return True #Reply has been added successfully |
3c8f3b0e5b00
Add support for buildout and move the files to the directory to support buildout structure.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
130 |
return False #Already replied |