diff options
author | nishanth | 2010-02-27 14:22:26 +0530 |
---|---|---|
committer | nishanth | 2010-02-27 14:22:26 +0530 |
commit | 6b2d9faeb5827ddfb1d6ab9ec1ff341d24a18b1a (patch) | |
tree | c264614a6c415c57e5981b81c4919fdfb8d01090 /taskapp/events | |
parent | 6c285ab73a09efdbeca1fb038fd3ee754d2e747a (diff) | |
download | pytask-6b2d9faeb5827ddfb1d6ab9ec1ff341d24a18b1a.tar.gz pytask-6b2d9faeb5827ddfb1d6ab9ec1ff341d24a18b1a.tar.bz2 pytask-6b2d9faeb5827ddfb1d6ab9ec1ff341d24a18b1a.zip |
notifications work for approving and rejecting credits.
Diffstat (limited to 'taskapp/events')
-rw-r--r-- | taskapp/events/request.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/taskapp/events/request.py b/taskapp/events/request.py index a104b8e..0bc1de0 100644 --- a/taskapp/events/request.py +++ b/taskapp/events/request.py @@ -1,6 +1,7 @@ from datetime import datetime from pytask.taskapp.events.task import addCredits, addMentor from pytask.taskapp.events.user import changeRole +from pytask.taskapp.utilities.notification import create_notification def reply_to_request(request_obj, reply, replied_by): """ @@ -18,15 +19,21 @@ def reply_to_request(request_obj, reply, replied_by): request_obj.save() 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: - print "send a no notificvaton" + ## note that we are not doing any check. we make requests invalid when an event like closing task happens. + task = request_obj.task + pynts = request_obj.pynts + receiving_user = request_obj.receiving_user + requested_by = request_obj.sent_by + for a_mentor in task.mentors.all(): + if reply: + addCredits(task, request_obj.sent_by, request_obj.receiving_user, pynts) + print "send yes notifications appropriately" + #def create_notification(role, sent_to, sent_from=None, reply=None, task=None, remark=None, receiving_user=None, pynts=None, requested_by): + create_notification("PY", a_mentor, replied_by, True, task, receiving_user, pynts, requested_by) + else: + print "send a no notificvaton" + create_notification("PY", a_mentor, replied_by, False, task, receiving_user, pynts, requested_by, request_obj.remarks) + elif request_obj.role == "MT": ## add him as a mentor to the task if reply: |