diff options
author | nishanth | 2010-03-01 11:52:00 +0530 |
---|---|---|
committer | nishanth | 2010-03-01 11:52:00 +0530 |
commit | 77312a19a2877e4650ebe55fc2fa596c968252ed (patch) | |
tree | 526697e8951ed0f73aa886b8867d23d3f425d62d /taskapp | |
parent | f9219059285e024c70c50ee4ade9053ed23934d7 (diff) | |
download | pytask-77312a19a2877e4650ebe55fc2fa596c968252ed.tar.gz pytask-77312a19a2877e4650ebe55fc2fa596c968252ed.tar.bz2 pytask-77312a19a2877e4650ebe55fc2fa596c968252ed.zip |
implemented nu nt nd ng na notifications.
Diffstat (limited to 'taskapp')
-rw-r--r-- | taskapp/events/request.py | 34 | ||||
-rw-r--r-- | taskapp/utilities/notification.py | 27 |
2 files changed, 48 insertions, 13 deletions
diff --git a/taskapp/events/request.py b/taskapp/events/request.py index 8d83851..fe2a643 100644 --- a/taskapp/events/request.py +++ b/taskapp/events/request.py @@ -57,11 +57,6 @@ def reply_to_request(request_obj, reply, replied_by): elif request_obj.role == "DV": if reply: - ## tell only the user who made him a DV - ## 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") @@ -71,14 +66,19 @@ def reply_to_request(request_obj, reply, replied_by): 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 ) + + ## tell only the user who made him a DV + ## drop a welcome message to that fucker + create_notification(request_obj.role, request_obj.sent_by, request_obj.replied_by, reply, requested_by=request_obj.sent_by) + create_notification("ND", request_obj.replied_by, requested_by=request_obj.sent_by) + changeRole(role=request_obj.role, user=request_obj.replied_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) elif request_obj.role == "MG": if reply: ## tell all the MG and AD - ## drop a welcome message to that fucker - changeRole(role=request_obj.role, user=request_obj.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) @@ -93,17 +93,16 @@ def reply_to_request(request_obj, reply, replied_by): 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 ) + + ## drop a welcome message to that fucker + create_notification("NG", request_obj.replied_by, requested_by=request_obj.sent_by) + changeRole(role=request_obj.role, user=request_obj.replied_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) elif request_obj.role == "AD": if reply: - ## tell all the AD - ## drop a welcome message to that fucker - changeRole(role=request_obj.role, user=request_obj.replied_by) - 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 @@ -115,6 +114,15 @@ def reply_to_request(request_obj, reply, replied_by): 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 ) + ## tell all the AD + 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) + + ## drop a welcome message to that fucker + create_notification("NA", request_obj.replied_by, requested_by=request_obj.sent_by) + changeRole(role=request_obj.role, user=request_obj.replied_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 16e80a1..e16a94f 100644 --- a/taskapp/utilities/notification.py +++ b/taskapp/utilities/notification.py @@ -115,6 +115,33 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re notification.message += "</ul><br />" notification.message += "Happy Mentoring." + elif role == "NU": + + start_here_url = '<a href="/about/starthere/" taget="_blank">start here</a>' + notification.sub = "Welcome %s"%sent_to.username + notification.message = "Welcome to PyTasks %s.<br />"%sent_to.username + notification.message += "If you are lost and have no clue, %s"%start_here_url + + elif role in ["ND", "NG", "NA"]: + + rights_dict = dict(RIGHTS_CHOICES) + + if role == "ND": + role_rights = rights_dict["DV"] + elif role == "NG": + role_rights = rights_dict["MG"] + elif role == "NA": + role_rights = rights_dict["AD"] + + requested_by_url = r'<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username) + role_learn_url = r'<a href="/about/%s" target="_blank">click here</a>'%role_rights.lower() + a_or_an = "an" if role_rights == "Admin" else "a" + + notification.sub = "You are now %s %s"%(a_or_an, role_rights) + notification.message = r"You have accepted the request made by %s asking you to act as %s %s in the site "%(requested_by_url, a_or_an, role_rights) + notification.message += "and you are now %s %s in the site.<br /> %s to learn more on %s."%(a_or_an, role_rights, role_learn_url, role_rights) + + elif role in ["CM", "CD"]: notification.sent_from = sent_from |