Commits

Anonymous committed 34a9fb9

added tests and templates

Comments (0)

Files changed (3)

django_easyfilters/templates/django-easyfilters/default.html

+<div class="filterline"><span class="filterlabel">{{ filterlabel }}:</span>
+{% for choice in choices %}
+  {% if choice.link_type == 'add' %}
+    <span class="addfilter"><a href="{{ choice.url }}" title="Add filter">{{ choice.label }}&nbsp;({{ choice.count }})</a></span>&nbsp;&nbsp;
+  {% else %}
+    {% if choice.link_type == 'remove' %}
+    <span class="removefilter"><a href="{{ choice.url }}" title="Remove filter">{{ choice.label }}&nbsp;&laquo;&nbsp;</a></span>
+    {% else %}
+      <span class="displayfilter">{{ choice.label }}</span>
+    {% endif %}
+  {% endif %}
+{% endfor %}
+</div>

django_easyfilters/tests/filterset.py

         rendered_2 = fs_filtered.render()
         self.assertTrue('Genre' in rendered_2)
 
+    def test_custom_template(self):
+        class BookFilterSet(FilterSet):
+            template_file = "ignore/this/non-existent/file"
+            template = u"Bogus empty template"
+            fields = [
+                'genre',
+                ]
+
+        qs = Book.objects.all()
+        fs = BookFilterSet(qs, QueryDict(''))
+        rendered = fs.render()
+        self.assertTrue('Bogus empty template' in rendered)
+        self.assertEqual(rendered, text_type(fs))
+
+    def test_custom_template_from_file(self):
+        class BookFilterSet(FilterSet):
+            template_file = "template_for_tests.html"
+            fields = [
+                'genre',
+                ]
+
+        qs = Book.objects.all()
+        fs = BookFilterSet(qs, QueryDict(''))
+        rendered = fs.render()
+        self.assertTrue('Bogus template from file for testing' in rendered)
+        self.assertEqual(rendered, text_type(fs))
+
+
     def test_get_filter_for_field(self):
         """
         Ensures that the get_filter_for_field method chooses appropriately.

django_easyfilters/tests/templates/template_for_tests.html

+Bogus template from file for testing