diff options
-rw-r--r-- | pytask/taskapp/urls.py | 5 | ||||
-rwxr-xr-x | pytask/taskapp/views.py | 29 | ||||
-rw-r--r-- | pytask/templates/task/browse.html | 39 | ||||
-rw-r--r-- | pytask/templates/task/browse_textbooks.html | 6 |
4 files changed, 74 insertions, 5 deletions
diff --git a/pytask/taskapp/urls.py b/pytask/taskapp/urls.py index f0a3b59..045ff89 100644 --- a/pytask/taskapp/urls.py +++ b/pytask/taskapp/urls.py @@ -2,7 +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_textbooks, edit_textbook, approve_task, approved_task,\ + browse_tasks from pytask.views import under_construction @@ -15,7 +16,7 @@ urlpatterns = patterns('', (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 --git a/pytask/taskapp/views.py b/pytask/taskapp/views.py index 2e9de9f..cabd8d3 100755 --- a/pytask/taskapp/views.py +++ b/pytask/taskapp/views.py @@ -59,6 +59,35 @@ def create_task(request): 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 --git a/pytask/templates/task/browse.html b/pytask/templates/task/browse.html new file mode 100644 index 0000000..46a93c0 --- /dev/null +++ b/pytask/templates/task/browse.html @@ -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 %} diff --git a/pytask/templates/task/browse_textbooks.html b/pytask/templates/task/browse_textbooks.html index 3d2edd0..0542a8e 100644 --- a/pytask/templates/task/browse_textbooks.html +++ b/pytask/templates/task/browse_textbooks.html @@ -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 %} |