diff options
author | nishanth | 2010-02-27 00:48:50 +0530 |
---|---|---|
committer | nishanth | 2010-02-27 00:48:50 +0530 |
commit | 35cac9b34425e63e63a4c4ca5376bdf513550af4 (patch) | |
tree | ef7e95adf3dbbef9ae1091b1a1aac4df1edf21c5 /taskapp | |
parent | b0450c263fa86411c64f37781f2237e0c296e0ed (diff) | |
download | pytask-35cac9b34425e63e63a4c4ca5376bdf513550af4.tar.gz pytask-35cac9b34425e63e63a4c4ca5376bdf513550af4.tar.bz2 pytask-35cac9b34425e63e63a4c4ca5376bdf513550af4.zip |
added the functionality to close a task.
Diffstat (limited to 'taskapp')
-rw-r--r-- | taskapp/events/task.py | 16 | ||||
-rw-r--r-- | taskapp/views/task.py | 39 |
2 files changed, 52 insertions, 3 deletions
diff --git a/taskapp/events/task.py b/taskapp/events/task.py index 20bb1c6..d62216b 100644 --- a/taskapp/events/task.py +++ b/taskapp/events/task.py @@ -222,9 +222,23 @@ def completeTask(task, marked_by): task.status = "CM" task.save() - task.request_task.filter(is_replied=False).update(is_valid=False) + pending_requests = task.request_task.filter(is_replied=False) + pending_requests.update(is_valid=False) ## generate notification appropriately using marked_by ## we also have to mark unread requests as invalid +def closeTask(task, closed_by): + """ set the status of task as CD. + generate notifications accordingly. + """ + + task.status = "CD" + task.save() + + pending_requests = task.request_task.filter(is_replied=False) + pending_requests.update(is_valid=False) + + ## generate notifications here + diff --git a/taskapp/views/task.py b/taskapp/views/task.py index fe7349c..44f94df 100644 --- a/taskapp/views/task.py +++ b/taskapp/views/task.py @@ -6,7 +6,7 @@ from django.shortcuts import render_to_response, redirect from pytask.taskapp.models import User, Task, Comment, Claim, Credit from pytask.taskapp.utilities.task import getTask 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, updateTask, removeTask, removeUser, assignCredits, completeTask +from pytask.taskapp.events.task import createTask, reqMentor, publishTask, addSubTask, addDep, addClaim, assignTask, updateTask, removeTask, removeUser, assignCredits, completeTask, closeTask 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 @@ -83,7 +83,7 @@ def view_task(request, tid): } context['can_publish'] = True if task.status == "UP" and user == task.created_by else False - context['task_viewable'] = True if ( task.status not in ["UP", "DL"] ) or is_mentor else False + context['task_viewable'] = True if ( task.status != "DL" ) or is_mentor else False context['task_claimable'] = True if task.status in ["OP", "WR"] else False context['can_mod_mentors'] = True if task.status in ["UP", "OP", "LO", "WR"] and is_mentor else False @@ -513,3 +513,38 @@ def complete_task(request, tid): else: return show_msg(user, "You are not authorised to do this", task_url, "view the task") +def close_task(request, tid): + """ task can be closed only if task is published. + call the event close task if everything is fine. + """ + + 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 + + if is_mentor: + + context = { + 'user':user, + 'task':task, + } + + if not task.status in ["UP", "CD", "DL", "CM"]: + if request.method == "POST": + data = request.POST + if not data.get("reason", None): + context["error"] = "Please enter a reason for closing the task" + return render_to_response('task/close.html', context) + else: + closeTask(task, user) + return show_msg(user, "The task has been closed.", task_url, "view the task.") + else: + return render_to_response('task/close.html', context) + else: + return show_msg(user, "The task is already closed or the task cannot be closed 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") |