Textbooks list page should list all the tasks tagged with textbooks.
--- a/pytask/taskapp/views.py Thu Jan 20 06:36:38 2011 +0530
+++ b/pytask/taskapp/views.py Thu Jan 20 07:17:14 2011 +0530
@@ -487,20 +487,27 @@
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')
- 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 = {'open_textbooks': open_textbooks,}
+
+ # 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})
--- a/pytask/templates/task/browse_textbooks.html Thu Jan 20 06:36:38 2011 +0530
+++ b/pytask/templates/task/browse_textbooks.html Thu Jan 20 07:17:14 2011 +0530
@@ -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 %}