browse tasks works fine now
authorNishanth Amuluru <nishanth@fossee.in>
Tue, 11 Jan 2011 11:51:12 +0530
changeset 376 5a94c774473c
parent 375 40f1ef7a46d8
child 377 4f0cfd486d9b
browse tasks works fine now
pytask/taskapp/urls.py
pytask/taskapp/views.py
pytask/templates/task/browse.html
pytask/templates/task/browse_textbooks.html
--- a/pytask/taskapp/urls.py	Tue Jan 11 11:30:14 2011 +0530
+++ b/pytask/taskapp/urls.py	Tue Jan 11 11:51:12 2011 +0530
@@ -2,7 +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_textbooks, edit_textbook, approve_task, approved_task,\
+        browse_tasks
 
 from pytask.views import under_construction
 
@@ -15,7 +16,7 @@
             (r'^select/tid=(\w+)$', select_user),
             (r'^approve/tid=(\w+)$', approve_task),
             (r'^approved/tid=(\w+)$', approved_task),
-            (r'^browse/$', under_construction),
+            (r'^browse/$', browse_tasks),
 
             (r'^textbook/create/$', create_textbook),
             (r'^textbook/view/tid=(\w+)/$', view_textbook),
--- a/pytask/taskapp/views.py	Tue Jan 11 11:30:14 2011 +0530
+++ b/pytask/taskapp/views.py	Tue Jan 11 11:51:12 2011 +0530
@@ -59,6 +59,35 @@
     else:
         return show_msg(user, 'You are not authorised to create a task.')
 
+def browse_tasks(request):
+
+    open_tasks = Task.objects.filter(status="OP")
+    working_tasks = Task.objects.filter(status="WR")
+    comp_tasks = Task.objects.filter(status="CM")
+
+    context = {"open_tasks": open_tasks,
+               "working_tasks": working_tasks,
+               "comp_tasks": comp_tasks,
+              }
+
+    user = request.user
+    if not user.is_authenticated():
+        return render_to_response("task/browse.html")
+
+    profile = user.get_profile()
+
+    can_approve = True if profile.rights in ["MG", "DC"] else False
+    unpub_tasks = Task.objects.filter(status="UP").exclude(status="DL")
+    if can_approve:
+        context.update({"unpub_tasks": unpub_tasks})
+
+    context.update({"user": user,
+                    "profile": profile,
+                   })
+
+    return render_to_response("task/browse.html", context)
+
+
 def view_task(request, tid):
     """ get the task depending on its tid and display accordingly if it is a get.
     check for authentication and add a comment if it is a post request.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/templates/task/browse.html	Tue Jan 11 11:51:12 2011 +0530
@@ -0,0 +1,39 @@
+{% extends 'base.html' %}
+{% block content %}
+
+    {% if open_tasks %}
+    Tasks that are open for contribution<ul>
+    {% for task in open_tasks %}
+        <li><a href="/task/view/tid={{ task.uniq_key }}">{{ task.title }}</a></li>
+    {% endfor %}
+    </ul>
+    <br />
+    {% endif %}
+
+    {% if working_tasks %}
+    Tasks that are being worked on<ul>
+    {% for task in working_tasks %}
+        <li><a href="/task/view/tid={{ task.uniq_key }}">{{ task.title }}</a></li>
+    {% endfor %}
+    </ul>
+    <br />
+    {% endif %}
+
+    {% if comp_tasks %}
+    Tasks that were completed recently<ul>
+    {% for task in comp_tasks %}
+        <li><a href="/task/view/tid={{ task.uniq_key }}">{{ task.title }}</a></li>
+    {% endfor %}
+    </ul>
+    <br />
+    {% endif %}
+
+    {% if unpub_tasks %}
+    Tasks that need approval<ul>
+    {% for task in unpub_tasks %}
+        <li><a href="/task/view/tid={{ task.uniq_key }}">{{ task.title }}</a></li>
+    {% endfor %}
+    </ul>
+    <br />
+    {% endif %}
+{% endblock %}
--- a/pytask/templates/task/browse_textbooks.html	Tue Jan 11 11:30:14 2011 +0530
+++ b/pytask/templates/task/browse_textbooks.html	Tue Jan 11 11:51:12 2011 +0530
@@ -10,8 +10,8 @@
     {% endif %}
 
     {% if open_textbooks %}
-    textbooks that are open for contribution<ul>
-    {% for textbook in comp_textbooks %}
+    Textbooks that are open for contribution<ul>
+    {% for textbook in open_textbooks %}
         <li><a href="/task/textbook/view/tid={{ textbook.uniq_key }}">{{ textbook.name }}</a></li>
     {% endfor %}
     </ul>
@@ -19,7 +19,7 @@
     {% endif %}
 
     {% if unpub_textbooks %}
-    Textbooks that have been created but need approval<ul>
+    Textbooks that need approval<ul>
     {% for textbook in unpub_textbooks %}
         <li><a href="/task/textbook/view/tid={{ textbook.uniq_key }}">{{ textbook.name }}</a></li>
     {% endfor %}