From 11fecdb92d1bb571f8a40629c08a4ddeda7779d0 Mon Sep 17 00:00:00 2001
From: nishanth
Date: Sun, 28 Feb 2010 15:59:47 +0530
Subject: now accepting to be a MG deleted pending DV and MG reqs.
---
taskapp/events/request.py | 21 +++++++++++++++++++++
taskapp/utilities/notification.py | 2 +-
taskapp/views/user.py | 2 +-
3 files changed, 23 insertions(+), 2 deletions(-)
(limited to 'taskapp')
diff --git a/taskapp/events/request.py b/taskapp/events/request.py
index 2ad066b..747626a 100644
--- a/taskapp/events/request.py
+++ b/taskapp/events/request.py
@@ -64,6 +64,16 @@ def reply_to_request(request_obj, reply, replied_by):
## drop a welcome message to that fucker
changeRole(role=request_obj.role, user=request_obj.replied_by)
create_notification(request_obj.role, request_obj.sent_by, request_obj.replied_by, reply, requested_by=request_obj.sent_by)
+
+ ## here we look for requests that are similar => requesting for DV and make them invalid
+ ## also we drop a notification to user who made request
+ pending_requests = request_obj.replied_by.request_sent_to.filter(is_valid=True,is_replied=False,role="DV")
+ for req in pending_requests:
+ req.is_valid = False
+ req.save()
+ create_notification(role = req.role, sent_to = req.sent_by, sent_from = replied_by, reply = False, \
+ remarks = "User has accepted a similar request and has rights same or higher privileged than the request", \
+ requested_by = req.sent_by )
else:
create_notification(request_obj.role, request_obj.sent_by, request_obj.replied_by, reply, remarks=request_obj.remarks, requested_by=request_obj.sent_by)
@@ -75,6 +85,17 @@ def reply_to_request(request_obj, reply, replied_by):
alerting_users = Profile.objects.filter(user__is_active=True).exclude(rights="CT").exclude(rights="DV")
for a_profile in alerting_users:
create_notification(request_obj.role, a_profile.user, request_obj.replied_by, reply, requested_by=request_obj.sent_by)
+
+ ## here we look for requests that less or similar => requesting for DV or MG and make them invalid
+ ## also we drop a notification to user who made request
+ active_requests = request_obj.replied_by.request_sent_to.filter(is_valid=True,is_replied=False)
+ pending_requests = active_requests.filter(role="DV") | active_requests.filter(role="MG")
+ for req in pending_requests:
+ req.is_valid = False
+ req.save()
+ create_notification(role = req.role, sent_to = req.sent_by, sent_from = replied_by, reply = False, \
+ remarks = "User has accepted a similar request and has rights same or higher privileged than the request", \
+ requested_by = req.sent_by )
else:
create_notification(request_obj.role, request_obj.sent_by, request_obj.replied_by, reply, remarks=request_obj.remarks, requested_by=request_obj.sent_by)
diff --git a/taskapp/utilities/notification.py b/taskapp/utilities/notification.py
index 7ef646f..b1bc8a9 100644
--- a/taskapp/utilities/notification.py
+++ b/taskapp/utilities/notification.py
@@ -82,7 +82,7 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re
notification.message = "%s has accepted request made by %s asking him to act as %s %s for the website.
"%(user_url, requested_by_url, a_or_an, role_rights)
else:
notification.sub = "Rejected your request to act as %s"%role_rights
- notification.message = "%s has rejected your request asking him to act as a %s.
"%(new_mentor_url, task_url)
+ notification.message = "%s has rejected your request asking him to act as a %s.
"%(user_url, role_rights)
if remarks:
notification.message += "Remarks: %s
"%remarks
diff --git a/taskapp/views/user.py b/taskapp/views/user.py
index 9ccdcaf..9daae3c 100644
--- a/taskapp/views/user.py
+++ b/taskapp/views/user.py
@@ -279,7 +279,7 @@ def change_rights(request, role):
user_profile = user.get_profile()
user_rights = user_profile.rights
- user_can_view = True if user_rights == "AD" or ( user_rights == "MG" and role in ["mg", "dv"] ) else False
+ user_can_view = True if user_rights == "AD" or ( user_rights == "MG" and role in ["MG", "DV"] ) else False
if user_can_view:
if role == "DV":
--
cgit