# HG changeset patch # User Nishanth Amuluru # Date 1294726872 -19800 # Node ID 5a94c774473c31c7a0bc26e98b7131450508c9c4 # Parent 40f1ef7a46d8083b0c71b94b28042f2b26d5b29f browse tasks works fine now diff -r 40f1ef7a46d8 -r 5a94c774473c pytask/taskapp/urls.py --- 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), diff -r 40f1ef7a46d8 -r 5a94c774473c pytask/taskapp/views.py --- 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. diff -r 40f1ef7a46d8 -r 5a94c774473c pytask/templates/task/browse.html --- /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 +
+ {% endif %} + + {% if working_tasks %} + Tasks that are being worked on +
+ {% endif %} + + {% if comp_tasks %} + Tasks that were completed recently +
+ {% endif %} + + {% if unpub_tasks %} + Tasks that need approval +
+ {% endif %} +{% endblock %} diff -r 40f1ef7a46d8 -r 5a94c774473c pytask/templates/task/browse_textbooks.html --- 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