taskapp/views/task.py
changeset 108 131554cc3434
parent 105 091b044a3bf4
child 109 a381c91a1618
equal deleted inserted replaced
107:4903b4973fc8 108:131554cc3434
   107                     return render_to_response('task/create.html',{'form':form})
   107                     return render_to_response('task/create.html',{'form':form})
   108             else:
   108             else:
   109                 form = TaskCreateForm()
   109                 form = TaskCreateForm()
   110                 return render_to_response('task/create.html',{'form':form})
   110                 return render_to_response('task/create.html',{'form':form})
   111         else:
   111         else:
   112             return show_msg('You are not authorised to create a task.')
   112             return show_msg(user, 'You are not authorised to create a task.')
   113     else:
   113     else:
   114         return show_msg('You are not authorised to create a task.')
   114         return show_msg(user, 'You are not authorised to create a task.')
   115         
   115         
   116 def add_mentor(request, tid):
   116 def add_mentor(request, tid):
   117     """ check if the current user has the rights to edit the task and add him.
   117     """ check if the current user has the rights to edit the task and add him.
   118     if user is not authenticated, redirect him to concerned page. """
   118     if user is not authenticated, redirect him to concerned page. """
   119     
   119     
   149             return redirect(task_url)
   149             return redirect(task_url)
   150         else:
   150         else:
   151             return render_to_response('task/addmentor.html', {'form':form, 'errors':errors})
   151             return render_to_response('task/addmentor.html', {'form':form, 'errors':errors})
   152         
   152         
   153     else:
   153     else:
   154         return show_msg('You are not authorised to add mentors for this task', task_url, 'view the task')
   154         return show_msg(user, 'You are not authorised to add mentors for this task', task_url, 'view the task')
   155     
   155     
   156 def add_tasks(request, tid):
   156 def add_tasks(request, tid):
   157     """ first display tasks which can be subtasks for the task and do the rest.
   157     """ first display tasks which can be subtasks for the task and do the rest.
   158     """
   158     """
   159     
   159     
   207             else:
   207             else:
   208                 return render_to_response('task/addtask.html', {'user':user, 'form':form, 'errors':errors})
   208                 return render_to_response('task/addtask.html', {'user':user, 'form':form, 'errors':errors})
   209         else:
   209         else:
   210             errors = ["The task cannot be added subtasks or dependencies in this state"]
   210             errors = ["The task cannot be added subtasks or dependencies in this state"]
   211 #            return render_to_response('task/add.html', {'form':form, 'errors':errors})
   211 #            return render_to_response('task/add.html', {'form':form, 'errors':errors})
   212             return show_msg('The task cannot be added subtasks or dependencies now', task_url, 'view the task')
   212             return show_msg(user, 'The task cannot be added subtasks or dependencies now', task_url, 'view the task')
   213     else:
   213     else:
   214         return show_msg('You are not authorised to add subtasks or dependencies for this task', task_url, 'view the task')
   214         return show_msg(user, 'You are not authorised to add subtasks or dependencies for this task', task_url, 'view the task')
   215     
   215     
   216 def remove_task(request, tid):
   216 def remove_task(request, tid):
   217     """ display a list of tasks and remove the selectes ones.
   217     """ display a list of tasks and remove the selectes ones.
   218     """
   218     """
   219 
   219 
   245                 else:
   245                 else:
   246                     return render_to_response('task/removetask.html', {'user':user, 'form':form, 'errors':errors})
   246                     return render_to_response('task/removetask.html', {'user':user, 'form':form, 'errors':errors})
   247             else:
   247             else:
   248                 return render_to_response('task/removetask.html', {'user':user, 'form':form, 'errors':errors})
   248                 return render_to_response('task/removetask.html', {'user':user, 'form':form, 'errors':errors})
   249         else:
   249         else:
   250             return show_msg("The task has no subtasks/dependencies to be removed", task_url, "view the task")
   250             return show_msg(user, "The task has no subtasks/dependencies to be removed", task_url, "view the task")
   251     else:
   251     else:
   252         return show_msg("You are not authorised to do this", task_url, "view the task")
   252         return show_msg(user, "You are not authorised to do this", task_url, "view the task")
   253 
   253 
   254     
   254     
   255 def claim_task(request, tid):
   255 def claim_task(request, tid):
   256     """ display a list of claims for get and display submit only if claimable """
   256     """ display a list of claims for get and display submit only if claimable """
   257 
   257 
   297                 errors.append('Please fill up proposal in the field below')
   297                 errors.append('Please fill up proposal in the field below')
   298                 return render_to_response('task/claim.html', context)
   298                 return render_to_response('task/claim.html', context)
   299         else:
   299         else:
   300             return render_to_response('task/claim.html', context)
   300             return render_to_response('task/claim.html', context)
   301     else:
   301     else:
   302         return show_msg('You are not logged in to view claims for this task', task_url, 'view the task')
   302         return show_msg(user, 'You are not logged in to view claims for this task', task_url, 'view the task')
   303     
   303     
   304 def rem_user(request, tid):
   304 def rem_user(request, tid):
   305     """ show a list of working users and ask for a message/reason for removing user.
   305     """ show a list of working users and ask for a message/reason for removing user.
   306     """
   306     """
   307     
   307     
   339                     context['form'] = form
   339                     context['form'] = form
   340                     return render_to_response('task/remove_user.html', context)
   340                     return render_to_response('task/remove_user.html', context)
   341             else:
   341             else:
   342                 return render_to_response('task/remove_user.html',context)
   342                 return render_to_response('task/remove_user.html',context)
   343         else:
   343         else:
   344             return show_msg("There is no one working on this task to be kicked off", task_url, "view the task")
   344             return show_msg(user, "There is no one working on this task to be kicked off", task_url, "view the task")
   345     else:
   345     else:
   346         return show_msg("You are not authorised to do this", task_url, "view the task")
   346         return show_msg(user, "You are not authorised to do this", task_url, "view the task")
   347 
   347 
   348 def assign_task(request, tid):
   348 def assign_task(request, tid):
   349     """ first get the status of the task and then assign it to one of claimed users
   349     """ first get the status of the task and then assign it to one of claimed users
   350     generate list of claimed users by passing it as an argument to a function.
   350     generate list of claimed users by passing it as an argument to a function.
   351     """
   351     """
   374                 assignTask(task, assigned_user)
   374                 assignTask(task, assigned_user)
   375                 return redirect(task_url)
   375                 return redirect(task_url)
   376             else:
   376             else:
   377                 return render_to_response('task/assign.html',{'form':form})
   377                 return render_to_response('task/assign.html',{'form':form})
   378         elif assigned_users:
   378         elif assigned_users:
   379             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')
   379             return show_msg(user, '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')
   380         else:
   380         else:
   381             return show_msg('Wait for ppl to claim dude... slow and steady wins the race :)', task_url, 'view the task')
   381             return show_msg(user, 'Wait for ppl to claim dude... slow and steady wins the race :)', task_url, 'view the task')
   382     else:
   382     else:
   383         return show_msg('You are not authorised to perform this action', task_url, 'view the task')
   383         return show_msg(user, 'You are not authorised to perform this action', task_url, 'view the task')
   384 
   384 
   385 def assign_credits(request, tid):
   385 def assign_credits(request, tid):
   386     """ Check if the user is a mentor and credits can be assigned.
   386     """ Check if the user is a mentor and credits can be assigned.
   387     Then display all the approved credits.
   387     Then display all the approved credits.
   388     Then see if mentor can assign credits to users also or only mentors.
   388     Then see if mentor can assign credits to users also or only mentors.
   427                     context['form'] = form
   427                     context['form'] = form
   428                     return render_to_response('task/assigncredits.html', context)
   428                     return render_to_response('task/assigncredits.html', context)
   429             else:
   429             else:
   430                 return render_to_response('task/assigncredits.html', context)
   430                 return render_to_response('task/assigncredits.html', context)
   431         else:
   431         else:
   432             return show_msg("Credits cannot be assigned at this stage", task_url, "view the task")
   432             return show_msg(user, "Credits cannot be assigned at this stage", task_url, "view the task")
   433     else:
   433     else:
   434         return show_msg("You are not authorised to perform this action", task_url, "view the task")
   434         return show_msg(user, "You are not authorised to perform this action", task_url, "view the task")
   435 
   435 
   436 def edit_task(request, tid):
   436 def edit_task(request, tid):
   437     """ see what are the attributes that can be edited depending on the current status
   437     """ see what are the attributes that can be edited depending on the current status
   438     and then give the user fields accordingly.
   438     and then give the user fields accordingly.
   439     """
   439     """