--- 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),
)
--- 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)
--- /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 <a href="/task/textbook/view/tid={{textbook.uniq_key}}">{{textbook.name}}</a> has been approved.<br />
+The textbook will now be public.
+{% endblock %}
--- /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 <a href="/textbook/textbook/view/tid={{textbook.uniq_key}}">{{textbook.name}}</a><br />
+This action cannot be undone. Please confirm <br /> <br />
+
+<a href="/task/textbook/approved/tid={{textbook.uniq_key}}">Yes, I approve the textbook</a><br />
+<a href="/task/textbook/view/tid={{textbook.uniq_key}}">No, take me back to the textbook</a> <br />
+{% endblock %}