# HG changeset patch
# User nishanth
# Date 1267126994 -19800
# Node ID 4903b4973fc83e735aed232fa7ef8250d2d423fa
# Parent 3c3ea2a3f92a159bc8820399803b6e436ff4ad64
completed the process_request part.
diff -r 3c3ea2a3f92a -r 4903b4973fc8 taskapp/events/request.py
--- a/taskapp/events/request.py Fri Feb 26 00:29:04 2010 +0530
+++ b/taskapp/events/request.py Fri Feb 26 01:13:14 2010 +0530
@@ -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 @@
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 @@
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 @@
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 -r 3c3ea2a3f92a -r 4903b4973fc8 taskapp/events/user.py
--- a/taskapp/events/user.py Fri Feb 26 00:29:04 2010 +0530
+++ b/taskapp/events/user.py Fri Feb 26 01:13:14 2010 +0530
@@ -46,3 +46,11 @@
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 -r 3c3ea2a3f92a -r 4903b4973fc8 taskapp/models.py
--- a/taskapp/models.py Fri Feb 26 00:29:04 2010 +0530
+++ b/taskapp/models.py Fri Feb 26 01:13:14 2010 +0530
@@ -10,7 +10,7 @@
GENDER_CHOICES = (( 'M', 'Male'), ('F', 'Female'))
RIGHTS_CHOICES = (
("AD", "Admin"),
- ("MN", "Manager"),
+ ("MG", "Manager"),
("DV", "Developer"),
("CT", "Contributor"),)
diff -r 3c3ea2a3f92a -r 4903b4973fc8 templates/user/view_request.html
--- a/templates/user/view_request.html Fri Feb 26 00:29:04 2010 +0530
+++ b/templates/user/view_request.html Fri Feb 26 01:13:14 2010 +0530
@@ -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.