summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pytask/taskapp/urls.py6
-rwxr-xr-xpytask/taskapp/views.py42
-rw-r--r--pytask/templates/task/approved_textbook.html5
-rw-r--r--pytask/templates/task/confirm_textbook_approval.html8
4 files changed, 59 insertions, 2 deletions
diff --git a/pytask/taskapp/urls.py b/pytask/taskapp/urls.py
index 045ff89..7efc9be 100644
--- a/pytask/taskapp/urls.py
+++ b/pytask/taskapp/urls.py
@@ -2,8 +2,8 @@ from django.conf.urls.defaults import *
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 @@ urlpatterns = patterns('',
(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 --git a/pytask/taskapp/views.py b/pytask/taskapp/views.py
index 993703b..7d17c36 100755
--- a/pytask/taskapp/views.py
+++ b/pytask/taskapp/views.py
@@ -498,3 +498,45 @@ def select_user(request, tid):
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 --git a/pytask/templates/task/approved_textbook.html b/pytask/templates/task/approved_textbook.html
new file mode 100644
index 0000000..bb42cf8
--- /dev/null
+++ b/pytask/templates/task/approved_textbook.html
@@ -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 %}
diff --git a/pytask/templates/task/confirm_textbook_approval.html b/pytask/templates/task/confirm_textbook_approval.html
new file mode 100644
index 0000000..71d0f99
--- /dev/null
+++ b/pytask/templates/task/confirm_textbook_approval.html
@@ -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 %}