diff options
author | Madhusudan.C.S | 2011-01-20 07:17:14 +0530 |
---|---|---|
committer | Madhusudan.C.S | 2011-01-20 07:17:14 +0530 |
commit | af9eadb2c0546bf7a566f81503f977f74b2a845f (patch) | |
tree | 0b984703bfadb4efb128e111273e39186b9a2753 | |
parent | b547a8b15442a76603861d1d68e27f5a1548b295 (diff) | |
download | pytask-af9eadb2c0546bf7a566f81503f977f74b2a845f.tar.gz pytask-af9eadb2c0546bf7a566f81503f977f74b2a845f.tar.bz2 pytask-af9eadb2c0546bf7a566f81503f977f74b2a845f.zip |
Textbooks list page should list all the tasks tagged with textbooks.
-rwxr-xr-x | pytask/taskapp/views.py | 27 | ||||
-rw-r--r-- | pytask/templates/task/browse_textbooks.html | 24 |
2 files changed, 40 insertions, 11 deletions
diff --git a/pytask/taskapp/views.py b/pytask/taskapp/views.py index e9b9174..e383845 100755 --- a/pytask/taskapp/views.py +++ b/pytask/taskapp/views.py @@ -487,20 +487,27 @@ def view_textbook(request, task_id): RequestContext(request, context)) def browse_textbooks(request): + """View to list all the open textbooks. This view fetches tasks + tagged with Textbook. + """ user = request.user - open_textbooks = taskapp_models.TextBook.objects.filter(status=taskapp_models.TB_STATUS_CHOICES[1][0]).\ - order_by("creation_datetime") - comp_textbooks = taskapp_models.TextBook.objects.filter(status=taskapp_models.TB_STATUS_CHOICES[3][0]).\ - order_by("creation_datetime") - context = {"user": user, - "open_textbooks": open_textbooks, - "comp_textbooks": comp_textbooks, - } + # Fetch all the tasks tagged with Textbook + textbooks = taskapp_models.Task.tagged.with_any(['Textbook']) + + # Get all the textbooks that are Open. + open_textbooks = textbooks.filter( + status=taskapp_models.TASK_STATUS_CHOICES[1][0]).order_by( + 'creation_datetime') + + context = {'open_textbooks': open_textbooks,} - if user.is_authenticated() and user.get_profile().role in [profile_models.ROLES_CHOICES[0][0], profile_models.ROLES_CHOICES[1][0]]: - unpub_textbooks = taskapp_models.TextBook.objects.filter(status=taskapp_models.TB_STATUS_CHOICES[0][0]) + # Nothing + if user.is_authenticated() and (user.get_profile().role in + [profile_models.ROLES_CHOICES[0][0], profile_models.ROLES_CHOICES[1][0]]): + unpub_textbooks = taskapp_models.TextBook.objects.filter( + status=taskapp_models.TB_STATUS_CHOICES[0][0]) context.update({"unpub_textbooks": unpub_textbooks}) diff --git a/pytask/templates/task/browse_textbooks.html b/pytask/templates/task/browse_textbooks.html index 7797c2a..4bc7104 100644 --- a/pytask/templates/task/browse_textbooks.html +++ b/pytask/templates/task/browse_textbooks.html @@ -1,6 +1,27 @@ {% extends "base.html" %} {% block content %} + {% if open_textbooks %} + Textbooks that are open for contribution + <ul> + {% for textbook in open_textbooks %} + <li> + <a href="{% url view_textbook textbook.id %}"> + {{ textbook.title }} + </a> + </li> + {% endfor %} + </ul> + <br /> + {% endif %} + + + + + + <!-- TO BE REFORMATTED LATER. JUST PUSHING IT DOWN. --> + {% comment %} + {% if comp_textbooks %} Textbooks that were completed recently <ul> @@ -21,7 +42,7 @@ {% for textbook in open_textbooks %} <li> <a href="{% url view_textbook textbook.id %}"> - {{ textbook.name }} + {{ textbook.title }} </a> </li> {% endfor %} @@ -42,5 +63,6 @@ </ul> <br /> {% endif %} + {% endcomment %} {% endblock %} |