# HG changeset patch # User Nishanth Amuluru # Date 1294687984 -19800 # Node ID cdd8026ee60e8a5cfe3b2336c2606367ae607695 # Parent 014d812e625e0f018ec6b9f40641f8033be6c7c7 task approval is fine now diff -r 014d812e625e -r cdd8026ee60e pytask/taskapp/urls.py --- a/pytask/taskapp/urls.py Tue Jan 11 00:34:23 2011 +0530 +++ b/pytask/taskapp/urls.py Tue Jan 11 01:03:04 2011 +0530 @@ -2,7 +2,7 @@ from pytask.taskapp.views import create_task, view_task, claim_task, \ select_user, edit_task, create_textbook, view_textbook, \ - browse_textbooks, edit_textbook + browse_textbooks, edit_textbook, approve_task, approved_task from pytask.views import under_construction @@ -13,6 +13,8 @@ (r'^view/tid=(\w+)$', view_task), (r'^claim/tid=(\w+)$', claim_task), (r'^select/tid=(\w+)$', select_user), + (r'^approve/tid=(\w+)$', approve_task), + (r'^approved/tid=(\w+)$', approved_task), (r'^browse/$', under_construction), (r'^textbook/create/$', create_textbook), diff -r 014d812e625e -r cdd8026ee60e pytask/taskapp/views.py --- a/pytask/taskapp/views.py Tue Jan 11 00:34:23 2011 +0530 +++ b/pytask/taskapp/views.py Tue Jan 11 01:03:04 2011 +0530 @@ -181,6 +181,49 @@ return render_to_response("task/edit.html", context) @login_required +def approve_task(request, tid): + + user = request.user + profile = user.get_profile() + + task_url = "/task/view/tid=%s"%tid + task = getTask(tid) + + if profile.rights not in ["MG", "DC"] or task.status != "UP": + raise Http404 + + context = {"user": user, + "profile": profile, + "task": task, + } + + return render_to_response("task/confirm_approval.html", context) + +@login_required +def approved_task(request, tid): + + user = request.user + profile = user.get_profile() + + task_url = "/task/view/tid=%s"%tid + task = getTask(tid) + + if profile.rights not in ["MG", "DC"] or task.status != "UP": + raise Http404 + + task.approved_by = user + task.approval_datetime = datetime.now() + task.status = "OP" + task.save() + + context = {"user": user, + "profile": profile, + "task": task, + } + + return render_to_response("task/approved_task.html", context) + +@login_required def create_textbook(request): user = request.user diff -r 014d812e625e -r cdd8026ee60e pytask/templates/task/approved_task.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pytask/templates/task/approved_task.html Tue Jan 11 01:03:04 2011 +0530 @@ -0,0 +1,5 @@ +{% extends 'base.html' %} +{% block content %} +The task {{task.title}} has been approved.
+The task will be public. Now users can claim the task and work on it. +{% endblock %} diff -r 014d812e625e -r cdd8026ee60e pytask/templates/task/confirm_approval.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pytask/templates/task/confirm_approval.html Tue Jan 11 01:03:04 2011 +0530 @@ -0,0 +1,8 @@ +{% extends 'base.html' %} +{% block content %} +You are about to approve the task {{task.title}}
+This action cannot be undone. Please confirm

+ +Yes, I approve the task
+No, take me back to the task
+{% endblock %}