now adding mentor for a task happens through request. notifications still pending though
authornishanth
Fri, 26 Feb 2010 00:17:54 +0530
changeset 105 091b044a3bf4
parent 104 d1bdd5d6c1a6
child 106 3c3ea2a3f92a
now adding mentor for a task happens through request. notifications still pending though
taskapp/events/request.py
taskapp/events/task.py
taskapp/views/task.py
--- a/taskapp/events/request.py	Thu Feb 25 23:49:38 2010 +0530
+++ b/taskapp/events/request.py	Fri Feb 26 00:17:54 2010 +0530
@@ -1,5 +1,5 @@
 from datetime import datetime
-from pytask.taskapp.events.task import addCredits
+from pytask.taskapp.events.task import addCredits, addMentor
 
 def reply_to_request(request_obj, reply, replied_by):
     """
@@ -24,7 +24,13 @@
                 print "send a no notificvaton"
         elif request_obj.role == "MT":
             ## add him as a mentor to the task
-            pass
+            if reply:
+                addMentor(request_obj.task, request_obj.replied_by)
+                ## pass on notification of request_obj.sent_by
+            else:
+                print "request for mentor rejected"
+                ## pass on notification to request_obj.sent_by
+
         elif request_obj.role in ["AD", "MG", "DV"]:
             if reply:
                 pass
--- a/taskapp/events/task.py	Thu Feb 25 23:49:38 2010 +0530
+++ b/taskapp/events/task.py	Fri Feb 26 00:17:54 2010 +0530
@@ -75,6 +75,12 @@
     
     main_task.save()
 
+def reqMentor(task, mentor, req_by):
+    """ create a request object with role as MT.
+    """
+
+    create_request(sent_by=req_by, role="MT", sent_to=mentor, task=task) 
+
 def addMentor(task,mentor):
     """ add the mentor to mentors list of the task """
     
--- a/taskapp/views/task.py	Thu Feb 25 23:49:38 2010 +0530
+++ b/taskapp/views/task.py	Fri Feb 26 00:17:54 2010 +0530
@@ -5,7 +5,7 @@
 
 from pytask.taskapp.models import User, Task, Comment, Claim, Credit
 from pytask.taskapp.forms.task import TaskCreateForm, AddMentorForm, AddTaskForm, ChoiceForm, AssignCreditForm, RemoveUserForm
-from pytask.taskapp.events.task import createTask, addMentor, publishTask, addSubTask, addDep, addClaim, assignTask, getTask, updateTask, removeTask, removeUser, assignCredits
+from pytask.taskapp.events.task import createTask, reqMentor, publishTask, addSubTask, addDep, addClaim, assignTask, getTask, updateTask, removeTask, removeUser, assignCredits
 from pytask.taskapp.views.user import show_msg
 
 ## everywhere if there is no task, django should display 500 message.. but take care of that in sensitive views like add mentor and all
@@ -145,7 +145,7 @@
         if request.method == "POST":
             uid = request.POST['mentor']
             new_mentor = User.objects.get(id=uid)
-            addMentor(task, new_mentor)
+            reqMentor(task, new_mentor, user)
             return redirect(task_url)
         else:
             return render_to_response('task/addmentor.html', {'form':form, 'errors':errors})