From 522fbe3ea31327b893cc95b19bb8d7e66bd0de81 Mon Sep 17 00:00:00 2001
From: nishanth
Date: Fri, 26 Feb 2010 01:13:14 +0530
Subject: completed the process_request part.
---
taskapp/events/request.py | 11 +++++++++--
taskapp/events/user.py | 8 ++++++++
taskapp/models.py | 2 +-
templates/user/view_request.html | 12 ++++++++++++
4 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/taskapp/events/request.py b/taskapp/events/request.py
index 73ba5f9..a104b8e 100644
--- a/taskapp/events/request.py
+++ b/taskapp/events/request.py
@@ -1,5 +1,6 @@
from datetime import datetime
from pytask.taskapp.events.task import addCredits, addMentor
+from pytask.taskapp.events.user import changeRole
def reply_to_request(request_obj, reply, replied_by):
"""
@@ -18,6 +19,10 @@ def reply_to_request(request_obj, reply, replied_by):
if request_obj.role == "PY":
if reply:
+ ## note that we are not checking if he is stilla mentor
+ ## since we are not allowing removing mentors
+ ## if we allow, we have complications like removing unreplied requests made by this mentor and stuff.
+ ## but we check if this user is still an admin and put a notification if that you are no longer an admin and hence cannot do this.
addCredits(request_obj.task, request_obj.sent_by, request_obj.receiving_user, request_obj.pynts)
print "send yes notifications appropriately"
else:
@@ -25,6 +30,8 @@ def reply_to_request(request_obj, reply, replied_by):
elif request_obj.role == "MT":
## add him as a mentor to the task
if reply:
+ ## check for the current rights of request_obj.sent_by
+ ## what if he is no more a mentor to the task
addMentor(request_obj.task, request_obj.replied_by)
## pass on notification of request_obj.sent_by
else:
@@ -33,9 +40,9 @@ def reply_to_request(request_obj, reply, replied_by):
elif request_obj.role in ["AD", "MG", "DV"]:
if reply:
- pass
## make him the role
- ## changeRole(role=request_obj.role, made_by=request_obj.sent_by)
+ ## 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.
+ changeRole(role=request_obj.role, user=request_obj.replied_by)
else:
## notify request_obj.sent_by that it has been rejected
pass
diff --git a/taskapp/events/user.py b/taskapp/events/user.py
index e2ac30a..dab0ff2 100644
--- a/taskapp/events/user.py
+++ b/taskapp/events/user.py
@@ -46,3 +46,11 @@ def createSuUser(username,email,password,dob,gender):
su_user.is_superuser = True
su_user.save()
return su_user
+
+def changeRole(role, user):
+ """ change the status of user to role.
+ """
+
+ user_profile = user.get_profile()
+ user_profile.rights = role
+ user_profile.save()
diff --git a/taskapp/models.py b/taskapp/models.py
index 0a1a5d5..8e0a88a 100644
--- a/taskapp/models.py
+++ b/taskapp/models.py
@@ -10,7 +10,7 @@ from tagging.fields import TagField
GENDER_CHOICES = (( 'M', 'Male'), ('F', 'Female'))
RIGHTS_CHOICES = (
("AD", "Admin"),
- ("MN", "Manager"),
+ ("MG", "Manager"),
("DV", "Developer"),
("CT", "Contributor"),)
diff --git a/templates/user/view_request.html b/templates/user/view_request.html
index 5697768..75f9c9c 100644
--- a/templates/user/view_request.html
+++ b/templates/user/view_request.html
@@ -16,6 +16,18 @@
{% ifequal "MT" req.role %}
{{req.sent_by.username}} requested you to act as a mentor for the task
{{req.task.title}}
+ {% else %}
+ You have been requested to act as
+ {% ifequal "AD" req.role %}
+ an Admin
+ {% else %}
+ {% ifequal "MG" req.role %}
+ a Manager
+ {% else %}
+ a Developer
+ {% endifequal %}
+ {% endifequal %}
+ for the website by {{req.sent_by.username}}.
{% endifequal %}
Please accept or reject the request.
--
cgit