summaryrefslogtreecommitdiff
path: root/taskapp/views/task.py
diff options
context:
space:
mode:
authornishanth2010-02-26 13:22:13 +0530
committernishanth2010-02-26 13:22:13 +0530
commit783a2c959f365588849b2af728aa7e9b0c19bf02 (patch)
tree0c110808e97f728ef0e2d624739ef8a07de6c0de /taskapp/views/task.py
parent8f9406383064921f8cf50bad0a6d4f1bd06f9cb4 (diff)
downloadpytask-783a2c959f365588849b2af728aa7e9b0c19bf02.tar.gz
pytask-783a2c959f365588849b2af728aa7e9b0c19bf02.tar.bz2
pytask-783a2c959f365588849b2af728aa7e9b0c19bf02.zip
mark task as complete functionality is added.
Diffstat (limited to 'taskapp/views/task.py')
-rw-r--r--taskapp/views/task.py45
1 files changed, 44 insertions, 1 deletions
diff --git a/taskapp/views/task.py b/taskapp/views/task.py
index 443596a..b88a43e 100644
--- a/taskapp/views/task.py
+++ b/taskapp/views/task.py
@@ -5,7 +5,7 @@ from django.shortcuts import render_to_response, redirect
from pytask.taskapp.models import User, Task, Comment, Claim, Credit
from pytask.taskapp.forms.task import TaskCreateForm, AddMentorForm, AddTaskForm, ChoiceForm, AssignCreditForm, RemoveUserForm
-from pytask.taskapp.events.task import createTask, reqMentor, publishTask, addSubTask, addDep, addClaim, assignTask, getTask, updateTask, removeTask, removeUser, assignCredits
+from pytask.taskapp.events.task import createTask, reqMentor, publishTask, addSubTask, addDep, addClaim, assignTask, getTask, updateTask, removeTask, removeUser, assignCredits, completeTask
from pytask.taskapp.views.user import show_msg
## everywhere if there is no task, django should display 500 message.. but take care of that in sensitive views like add mentor and all
@@ -470,3 +470,46 @@ def edit_task(request, tid):
"""
task = Task.objects.get(id=tid)
+
+def complete_task(request, tid):
+
+ """ call the event called complete task.
+ and also pass it the current user to know who marked it as complete.
+ """
+
+ task_url = "/task/view/tid=%s"%tid
+
+ user = request.user
+ task = getTask(tid)
+
+ is_guest = True if not user.is_authenticated() else False
+ is_mentor = True if user in task.mentors.all() else False
+
+ claimed_users = task.claimed_users.all()
+ assigned_users = task.assigned_users.all()
+
+ assign_credits_url = '/task/assigncredits/tid=%s'%task.id
+ task_assigned_credits = task.credit_set.all()
+
+
+ if is_mentor:
+ if task.status in ["OP", "WR"]:
+
+ context = {
+ 'user':user,
+ 'task':task,
+ }
+
+ if task_assigned_credits:
+ if request.method=="POST":
+ completeTask(task, user)
+ return redirect(task_url)
+ else:
+ return render_to_response('task/complete.html', context)
+ else:
+ return show_msg(user, "Nobody has been credited for doing this task.", assign_credits_url, "assign credits")
+ else:
+ return show_msg(user, "The task cannot be marked as completed at this stage", task_url, "view the task")
+ else:
+ return show_msg(user, "You are not authorised to do this", task_url, "view the task")
+