# HG changeset patch # User nishanth # Date 1267353582 -19800 # Node ID 047473d49b257706766f6b322350bd51abe996bb # Parent 0c97a02b9bdbec97fb9fa820dcbb00be265eb1a2 now accepting an admin request will make all pending AD MG DV reqs as inactive. diff -r 0c97a02b9bdb -r 047473d49b25 taskapp/events/request.py --- a/taskapp/events/request.py Sun Feb 28 15:59:47 2010 +0530 +++ b/taskapp/events/request.py Sun Feb 28 16:09:42 2010 +0530 @@ -107,6 +107,17 @@ alerting_users = Profile.objects.filter(user__is_active=True).filter(rights="AD") 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 or AD 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") | active_requests.filter(role="AD") + 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)