Add templatetags for listing textbooks.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Thu, 20 Jan 2011 07:55:38 +0530
changeset 496 eb1982186306
parent 495 773e886d9b80
child 497 6386458d749b
Add templatetags for listing textbooks. This templatetag must be refactored to be utilized for tasks also.
pytask/templates/templatetags/_as_browse_textbooks.html
pytask/templatetags/browse_helpers.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/templates/templatetags/_as_browse_textbooks.html	Thu Jan 20 07:55:38 2011 +0530
@@ -0,0 +1,12 @@
+<h2>{{ title }}</h2>
+<h3>List of textbooks open for contribution</h3>
+<ul>
+  {% for task in tasks %}
+    <li>
+      <a href="{% url view_textbook task.id %}">
+        {{ task.title }}
+      </a>
+    </li>
+  {% endfor %}
+</ul>
+<br />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/templatetags/browse_helpers.py	Thu Jan 20 07:55:38 2011 +0530
@@ -0,0 +1,35 @@
+"""Module containing the templatetags for rendering data especially for
+browsing.
+"""
+
+
+__authors__ = [
+    '"Madhusudan.C.S" <madhusudancs@fossee.in>',
+    ]
+
+
+from django import template
+
+
+register = template.Library()
+
+
+@register.inclusion_tag('templatetags/_as_browse_textbooks.html')
+def as_list_textbooks(textbooks, title):
+    """Returns a dictionary required to display the list of tasks.
+    """
+
+    return {
+      'tasks': textbooks,
+      'title': title,
+      }
+
+
+@register.inclusion_tag('templatetags/_as_div_field.html')
+def as_div_field(field):
+    """Returns the field for each div form field.
+    """
+
+    return {
+      'field': field,
+      }