fixed a bug in add_claim view in views/task .
authornishanth
Wed, 24 Feb 2010 16:47:09 +0530
changeset 76 00a41fbf4958
parent 75 fa59955a340b
child 77 8f2906d1200a
fixed a bug in add_claim view in views/task .
taskapp/views/task.py
templates/task/view.html
--- a/taskapp/views/task.py	Wed Feb 24 16:35:09 2010 +0530
+++ b/taskapp/views/task.py	Wed Feb 24 16:47:09 2010 +0530
@@ -128,12 +128,15 @@
     if (not is_guest) and user in task.mentors.all():
         
         ## now iam going for a brute force method
-        user_list = list(User.objects.all())
+        user_list = list(User.objects.filter(is_active=True))
         for mentor in task.mentors.all():
             user_list.remove(mentor)
             
         for a_user in task.claimed_users.all():
             user_list.remove(a_user)
+
+        for a_user in task.assigned_users.all():
+            user_list.remove(a_user)
             
         non_mentors = ((_.id,_.username) for _ in user_list)
         ## code till must be made elegant and not brute force like above
@@ -196,12 +199,13 @@
 
     mentors = task.mentors.all()
     claimed_users = task.claimed_users.all()
+    assigned_users = task.assigned_users.all()
     
     is_guest = True if not user.is_authenticated() else False
     is_mentor = True if user in mentors else False
 
     task_claimable = True if task.status in ["OP", "WR"] else False
-    user_can_claim = True if  task_claimable and not ( is_guest or is_mentor ) and ( user not in claimed_users )  else False
+    user_can_claim = True if  task_claimable and not ( is_guest or is_mentor ) and ( user not in claimed_users ) and ( user not in assigned_users )  else False
     task_claimed = True if claimed_users else False
     
     context = {'user':user,
--- a/templates/task/view.html	Wed Feb 24 16:35:09 2010 +0530
+++ b/templates/task/view.html	Wed Feb 24 16:47:09 2010 +0530
@@ -13,7 +13,9 @@
             <a href="/user/view/uid={{mentor.id}}">{{mentor.username}}|</a>
         {% endfor %}
         {% if can_mod_mentors %}
-            <a href="/task/addmentor/tid={{task.id}}">Add another Mentor to this task</a><br />
+            <a href="/task/addmentor/tid={{task.id}}">Add another Mentor to this task</a>
+            <a href="/task/mentor/remove/tid={{task.id}}">Remove a mentor</a>
+            <br />
             edit task goes here and it should contain all those add subs and add deps depending on availability<br />
         {% endif %}