summaryrefslogtreecommitdiff
path: root/taskapp/views/task.py
diff options
context:
space:
mode:
authornishanth2010-02-26 02:52:32 +0530
committernishanth2010-02-26 02:52:32 +0530
commit8dff30125e4a169b28cdc8242041e4e92b5b0718 (patch)
tree4d7659e6e58fa74b0606c46eda55c7e2fdc5edfd /taskapp/views/task.py
parent2c09c0568eb24349fed6654451115839e3d92b55 (diff)
downloadpytask-8dff30125e4a169b28cdc8242041e4e92b5b0718.tar.gz
pytask-8dff30125e4a169b28cdc8242041e4e92b5b0718.tar.bz2
pytask-8dff30125e4a169b28cdc8242041e4e92b5b0718.zip
added the functionality to publish a task.
Diffstat (limited to 'taskapp/views/task.py')
-rw-r--r--taskapp/views/task.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/taskapp/views/task.py b/taskapp/views/task.py
index 93e4722..443d84e 100644
--- a/taskapp/views/task.py
+++ b/taskapp/views/task.py
@@ -22,6 +22,33 @@ def browse_tasks(request):
}
return render_to_response('task/browse.html', context)
+def publish_task(request, tid):
+ """ check if user is the mentor and also if the task status is UP.
+ """
+
+ 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 user==task.created_by:
+ context = {
+ 'user':user,
+ }
+
+ if request.method == "POST":
+ publishTask(task)
+ return show_msg(user, "The task has been published", task_url, "view the task")
+ else:
+ return render_to_response('task/publish.html', context)
+ else:
+ return show_msg(user, "You are not authorised to do this", '/task/browse/', "browse tasks")
+
+
+
def view_task(request, tid):
""" get the task depending on its tid and display accordingly if it is a get.
check for authentication and add a comment if it is a post request.
@@ -54,6 +81,7 @@ def view_task(request, tid):
'errors':errors,
}
+ 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_claimable'] = True if task.status in ["OP", "WR"] else False