# HG changeset patch # User Nishanth Amuluru # Date 1294736425 -19800 # Node ID e848bd3ad41f4d145832f6887cca0bd31424ad06 # Parent ed2dadfc829aa65ced281fca3de2b20053fdc59f approval of textbooks works now diff -r ed2dadfc829a -r e848bd3ad41f pytask/taskapp/urls.py --- a/pytask/taskapp/urls.py Tue Jan 11 12:36:55 2011 +0530 +++ b/pytask/taskapp/urls.py Tue Jan 11 14:30:25 2011 +0530 @@ -2,8 +2,8 @@ from pytask.taskapp.views import create_task, view_task, claim_task, \ select_user, edit_task, create_textbook, view_textbook, \ - browse_textbooks, edit_textbook, approve_task, approved_task,\ - browse_tasks + browse_tasks, edit_textbook, approve_task, approved_task,\ + browse_textbooks, approve_textbook, approved_textbook from pytask.views import under_construction @@ -21,6 +21,8 @@ (r'^textbook/create/$', create_textbook), (r'^textbook/view/tid=(\w+)/$', view_textbook), (r'^textbook/edit/tid=(\w+)/$', edit_textbook), + (r'^textbook/approve/tid=(\w+)/$', approve_textbook), + (r'^textbook/approved/tid=(\w+)/$', approved_textbook), (r'^textbook/browse/$', browse_textbooks), ) diff -r ed2dadfc829a -r e848bd3ad41f pytask/taskapp/views.py --- a/pytask/taskapp/views.py Tue Jan 11 12:36:55 2011 +0530 +++ b/pytask/taskapp/views.py Tue Jan 11 14:30:25 2011 +0530 @@ -498,3 +498,45 @@ else: raise Http404 +@login_required +def approve_textbook(request, tid): + + user = request.user + profile = user.get_profile() + + textbook_url = "/task/view/tid=%s"%tid + textbook = getTextBook(tid) + + if profile.rights not in ["MG", "DC"] or textbook.status != "UP": + raise Http404 + + context = {"user": user, + "profile": profile, + "textbook": textbook, + } + + return render_to_response("task/confirm_textbook_approval.html", context) + +@login_required +def approved_textbook(request, tid): + + user = request.user + profile = user.get_profile() + + textbook_url = "/task/view/tid=%s"%tid + textbook = getTextBook(tid) + + if profile.rights not in ["MG", "DC"] or textbook.status != "UP": + raise Http404 + + textbook.approved_by = user + textbook.approval_datetime = datetime.now() + textbook.status = "OP" + textbook.save() + + context = {"user": user, + "profile": profile, + "textbook": textbook, + } + + return render_to_response("task/approved_textbook.html", context) diff -r ed2dadfc829a -r e848bd3ad41f pytask/templates/task/approved_textbook.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pytask/templates/task/approved_textbook.html Tue Jan 11 14:30:25 2011 +0530 @@ -0,0 +1,5 @@ +{% extends 'base.html' %} +{% block content %} +The textbook {{textbook.name}} has been approved.
+The textbook will now be public. +{% endblock %} diff -r ed2dadfc829a -r e848bd3ad41f pytask/templates/task/confirm_textbook_approval.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pytask/templates/task/confirm_textbook_approval.html Tue Jan 11 14:30:25 2011 +0530 @@ -0,0 +1,8 @@ +{% extends 'base.html' %} +{% block content %} +You are about to approve the textbook {{textbook.name}}
+This action cannot be undone. Please confirm

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