From d2bb8bee31479c7c4fadfced462d2f876d8a019b Mon Sep 17 00:00:00 2001 From: nishanth Date: Wed, 24 Feb 2010 16:08:31 +0530 Subject: modified claim_task view to suit the new design --- taskapp/views/task.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'taskapp') diff --git a/taskapp/views/task.py b/taskapp/views/task.py index 3e5119b..df56a1c 100644 --- a/taskapp/views/task.py +++ b/taskapp/views/task.py @@ -193,18 +193,19 @@ def claim_task(request, tid): user = request.user task = getTask(tid) claims = Claim.objects.filter(task=task) + + mentors = task.mentors.all() + claimed_users = task.claimed_users.all() is_guest = True if not user.is_authenticated() else False - if user in task.mentors.all(): - is_mentor = True - else: - is_mentor = False + is_mentor = True if user in mentors else False - task_claimable = True if task.status in ["OP", "RE", "CL"] else False - user_can_claim = True if task_claimable and not ( is_guest or is_mentor ) and ( user not in task.claimed_users.all() ) else False - task_claimed = True if task.status == "CL" 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 + task_claimed = True if claimed_users else False - context = {'is_mentor':is_mentor, + context = {'user':user, + 'is_mentor':is_mentor, 'task':task, 'claims':claims, 'user_can_claim':user_can_claim, @@ -268,4 +269,4 @@ def edit_task(request, tid): and then give the user fields accordingly. """ - return None + task = Task.objects.get(id=tid) -- cgit From 4cd3302dce9ff14478c43b80803f5963b571d243 Mon Sep 17 00:00:00 2001 From: nishanth Date: Wed, 24 Feb 2010 16:16:41 +0530 Subject: fixed a bug. --- taskapp/events/task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'taskapp') diff --git a/taskapp/events/task.py b/taskapp/events/task.py index 3712dbd..ed56ade 100644 --- a/taskapp/events/task.py +++ b/taskapp/events/task.py @@ -120,7 +120,7 @@ def updateTask(task, title=None, desc=None, credits=None, tags_field=None): try: task.title = title task.save() - except IntegrityError: + except Task.IntegrityError: return None if desc:task.desc = desc if credits:task.credits = credits -- cgit From 93db3491fd51a5b472b885dbf44534425289037a Mon Sep 17 00:00:00 2001 From: nishanth Date: Wed, 24 Feb 2010 16:35:09 +0530 Subject: modified the assign task view to suit the new design --- taskapp/views/task.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'taskapp') diff --git a/taskapp/views/task.py b/taskapp/views/task.py index df56a1c..0cbc3c9 100644 --- a/taskapp/views/task.py +++ b/taskapp/views/task.py @@ -241,11 +241,14 @@ def assign_task(request, tid): is_guest = True if not user.is_authenticated() else False is_mentor = True if user in task.mentors.all() else False - task_claimed = True if task.status == "CL" else False + claimed_users = task.claimed_users.all() + assigned_users = task.assigned_users.all() + + 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 task.claimed_users.all()) + user_list = ((user.id,user.username) for user in claimed_users) form = AssignTaskForm(user_list) if request.method == "POST": @@ -255,12 +258,10 @@ def assign_task(request, tid): return redirect(task_url) else: return render_to_response('task/assign.html',{'form':form}) - elif task.status == "AS": - return show_msg('The task is already assigned', task_url, 'view the task') - elif task.status == "OP": - return show_msg('No one has still claimed the task', task_url, 'view the task') + elif assigned_users: + 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') else: - return show_msg('The task status is %s. how can you assign it now'%task.status, task_url, 'view the task') + return show_msg('Wait for ppl to claim dude... slow and steady wins the race :)', task_url, 'view the task') else: return show_msg('You are not authorised to perform this action', task_url, 'view the task') -- cgit From fa1f14ca448e02e997ac1c1b8d1075b2596bb212 Mon Sep 17 00:00:00 2001 From: nishanth Date: Wed, 24 Feb 2010 16:47:09 +0530 Subject: fixed a bug in add_claim view in views/task . --- taskapp/views/task.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'taskapp') diff --git a/taskapp/views/task.py b/taskapp/views/task.py index 0cbc3c9..d81983a 100644 --- a/taskapp/views/task.py +++ b/taskapp/views/task.py @@ -128,12 +128,15 @@ def add_mentor(request, tid): 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 @@ def claim_task(request, tid): 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, -- cgit