task approval is fine now
authorNishanth Amuluru <nishanth@fossee.in>
Tue, 11 Jan 2011 01:03:04 +0530
changeset 374 cdd8026ee60e
parent 373 014d812e625e
child 375 40f1ef7a46d8
task approval is fine now
pytask/taskapp/urls.py
pytask/taskapp/views.py
pytask/templates/task/approved_task.html
pytask/templates/task/confirm_approval.html
--- 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),
--- 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
--- /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 <a href="/task/view/tid={{task.uniq_key}}">{{task.title}}</a> has been approved.<br />
+The task will be public. Now users can claim the task and work on it.
+{% endblock %}
--- /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 <a href="/task/view/tid={{task.uniq_key}}">{{task.title}}</a><br />
+This action cannot be undone. Please confirm <br /> <br />
+
+<a href="/task/approved/tid={{task.uniq_key}}">Yes, I approve the task</a><br />
+<a href="/task/view/tid={{task.uniq_key}}">No, take me back to the task</a> <br />
+{% endblock %}