summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornishanth2010-02-26 01:13:14 +0530
committernishanth2010-02-26 01:13:14 +0530
commit522fbe3ea31327b893cc95b19bb8d7e66bd0de81 (patch)
tree64cacbfeb9b4eda7833209aa6c035bb460134ae8
parent43b0dec7d77b9c9c59117b3b2db83aa6d56f2708 (diff)
downloadpytask-522fbe3ea31327b893cc95b19bb8d7e66bd0de81.tar.gz
pytask-522fbe3ea31327b893cc95b19bb8d7e66bd0de81.tar.bz2
pytask-522fbe3ea31327b893cc95b19bb8d7e66bd0de81.zip
completed the process_request part.
-rw-r--r--taskapp/events/request.py11
-rw-r--r--taskapp/events/user.py8
-rw-r--r--taskapp/models.py2
-rw-r--r--templates/user/view_request.html12
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 %}
<a href="/user/view/uid={{req.sent_by.id}}">{{req.sent_by.username}}</a> requested you to act as a mentor for the task
<a href="/task/view/tid={{req.task.id}}">{{req.task.title}}</a><br />
+ {% 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 <a href="/user/view/uid={{req.sent_by.id}}">{{req.sent_by.username}}</a>.<br />
{% endifequal %}
Please accept or reject the request.<br />