From d4f962bee5bbdc6c8892c330e71dd104ff2dbb20 Mon Sep 17 00:00:00 2001 From: nishanth Date: Mon, 1 Mar 2010 04:54:08 +0530 Subject: fixed assign_task method to display a not_allowed message if task status not in OP WR. --- taskapp/views/task.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'taskapp/views/task.py') diff --git a/taskapp/views/task.py b/taskapp/views/task.py index 02bfb62..de4e486 100644 --- a/taskapp/views/task.py +++ b/taskapp/views/task.py @@ -420,21 +420,24 @@ def assign_task(request, tid): task_claimed = True if claimed_users else False if (not is_guest) and is_mentor: - if task_claimed: - user_list = ((user.id,user.username) for user in claimed_users) - form = ChoiceForm(user_list) - - if request.method == "POST": - uid = request.POST['choice'] - assigned_user = User.objects.get(id=uid) - assignTask(task, assigned_user, user) - return redirect(task_url) + if task.status in ["OP", "WR"]: + if task_claimed: + user_list = ((user.id,user.username) for user in claimed_users) + form = ChoiceForm(user_list) + + if request.method == "POST": + uid = request.POST['choice'] + assigned_user = User.objects.get(id=uid) + assignTask(task, assigned_user, user) + return redirect(task_url) + else: + return render_to_response('task/assign.html',{'user':user, 'task':task,'form':form}) + elif assigned_users: + 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') else: - return render_to_response('task/assign.html',{'user':user, 'task':task,'form':form}) - elif assigned_users: - 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') - else: - return show_msg(user, 'Wait for ppl to claim dude... slow and steady wins the race :)', task_url, 'view the task') + return show_msg(user, 'Wait for ppl to claim dude... slow and steady wins the race :)', task_url, 'view the task') + else: + return show_msg(user, "The task cannot be assigned to users at this stage", task_url, 'view the task') else: return show_msg(user, 'You are not authorised to perform this action', task_url, 'view the task') @@ -450,6 +453,10 @@ def assign_credits(request, tid): user = get_user(request.user) if request.user.is_authenticated() else request.user task = getTask(tid) + ## the moment we see that user had requested credits, it means he had worked and hence we change the status to WR + task.status = "WR" + task.save() + is_guest = True if not user.is_authenticated() else False is_mentor = True if (not is_guest) and user in task.mentors.all() else False -- cgit