taskapp/views/task.py
changeset 75 fa59955a340b
parent 72 9fc60a221016
child 76 00a41fbf4958
equal deleted inserted replaced
74:7dc764854867 75:fa59955a340b
   239     task = getTask(tid)
   239     task = getTask(tid)
   240     
   240     
   241     is_guest = True if not user.is_authenticated() else False
   241     is_guest = True if not user.is_authenticated() else False
   242     is_mentor = True if user in task.mentors.all() else False
   242     is_mentor = True if user in task.mentors.all() else False
   243 
   243 
   244     task_claimed = True if task.status == "CL" else False
   244     claimed_users = task.claimed_users.all()
       
   245     assigned_users = task.assigned_users.all()
       
   246 
       
   247     task_claimed = True if claimed_users else False
   245     
   248     
   246     if (not is_guest) and is_mentor:
   249     if (not is_guest) and is_mentor:
   247         if task_claimed:
   250         if task_claimed:
   248             user_list = ((user.id,user.username) for user in task.claimed_users.all())
   251             user_list = ((user.id,user.username) for user in claimed_users)
   249             form = AssignTaskForm(user_list)
   252             form = AssignTaskForm(user_list)
   250     
   253     
   251             if request.method == "POST":
   254             if request.method == "POST":
   252                 uid = request.POST['user']
   255                 uid = request.POST['user']
   253                 assigned_user = User.objects.get(id=uid)
   256                 assigned_user = User.objects.get(id=uid)
   254                 assignTask(task, assigned_user)
   257                 assignTask(task, assigned_user)
   255                 return redirect(task_url)
   258                 return redirect(task_url)
   256             else:
   259             else:
   257                 return render_to_response('task/assign.html',{'form':form})
   260                 return render_to_response('task/assign.html',{'form':form})
   258         elif task.status == "AS":
   261         elif assigned_users:
   259             return show_msg('The task is already assigned', task_url, 'view the task')
   262             return show_msg('When the no of users you need for the task is more than the no of users willing to do the task, I\'d say please re consider the task :P',task_url, 'view the task')
   260         elif task.status == "OP":
   263         else:
   261             return show_msg('No one has still claimed the task', task_url, 'view the task')
   264             return show_msg('Wait for ppl to claim dude... slow and steady wins the race :)', task_url, 'view the task')
   262         else:
       
   263             return show_msg('The task status is %s. how can you assign it now'%task.status, task_url, 'view the task')
       
   264     else:
   265     else:
   265         return show_msg('You are not authorised to perform this action', task_url, 'view the task')
   266         return show_msg('You are not authorised to perform this action', task_url, 'view the task')
   266         
   267         
   267 def edit_task(request, tid):
   268 def edit_task(request, tid):
   268     """ see what are the attributes that can be edited depending on the current status
   269     """ see what are the attributes that can be edited depending on the current status