Commits

Patrick Samson committed bbf231a

Remove the dependency to django-pagination in the default template set

Comments (0)

Files changed (6)

 
 **I don't want to bother with the moderation feature, how to bypass it?**
     Set the configuration option::
-    
+
         POSTMAN_AUTO_MODERATE_AS = True
-    
+
+**I installed django-pagination, and still I don't see any pagination widgets**
+
+* Is there really more messages than one page capacity (default is 20)?
+* Check that ``pagination`` is declared before ``postman`` in the ``INSTALLED_APPS`` setting.
+* See if it's better by disabling :file:`postman/templatetags/pagination_tags.py` and :file:`.pyc` (rename or move the files).

docs/tags-filters.rst

 * :file:`postman_admin_modify.py`: a library exclusively designed for a customized change_form
   template used in the Admin site for the moderation of pending messages.
 
-* :file:`pagination_tags_for_tests.py`: a mock of the django-pagination application template tags,
-  only usable for the test suite in case the real application is not installed.
-  To rename to :file:`pagination_tags.py` during the test session.
+* :file:`pagination_tags.py`: a mock of the django-pagination application template tags.
+  For convenience, the design of the default template set is done with the use of that application.
+  The mock will avoid failures in template rendering if the real application is not installed,
+  as it may be the case for the test suite run in a minimal configuration.
+  To deactivate the mock and use the real implementation, just make sure that ``pagination`` is declared
+  before ``postman`` in the ``INSTALLED_APPS`` setting.
 
 Tags
 ----

postman/templates/postman/base_folder.html

 {% extends "postman/base.html" %}
 {% load url from future %}
-{% load i18n postman_tags %}{% load pagination_tags %}
+{% load i18n postman_tags %}{% load pagination_tags %}{% comment %}
+WARNING: 'pagination_tags' is a name from the django-pagination application.
+For convenience, the design of this template is done with the use of that application.
+Django-postman will still be working, even if that application is not installed, by providing a mock
+for the template tag library.
+If the real implementation is to be used, just make sure that 'pagination' is declared before 'postman'
+in the INSTALLED_APPS setting.
+{% endcomment %}
 {% block content %}
 <div id="postman">
 <h1>{% block pm_folder_title %}{% endblock %}</h1>

postman/templatetags/pagination_tags.py

+"""
+A mock of django-pagination's pagination_tags.py that does nothing.
+
+'pagination_tags' is a name from the django-pagination application.
+For convenience, the design of the default template set is done with the use of that application.
+This mock will avoid failures in template rendering if the real application is not installed,
+as it may be the case for the test suite run in a minimal configuration.
+
+To deactivate this mock and use the real implementation, just make sure that 'pagination' is declared
+before 'postman' in the INSTALLED_APPS setting.
+"""
+from django.template import Node, Library
+
+register = Library()
+
+class AutoPaginateNode(Node):
+    def render(self, context):
+        return u''
+
+@register.tag
+def autopaginate(parser, token):
+    return AutoPaginateNode()
+
+class PaginateNode(Node):
+    def render(self, context):
+        return u''
+
+@register.tag
+def paginate(parser, token):
+    return PaginateNode()

postman/templatetags/pagination_tags_for_tests.py

-"""
-A mock of django-pagination's pagination_tags.py that do nothing.
-Just to avoid failures in template rendering during the test suite,
-if the real application is not installed.
-
-To activate this mock, just rename it to ``pagination_tags.py``
-for the time of the test session.
-"""
-from django.template import Node, Library
-
-register = Library()
-
-class AutoPaginateNode(Node):
-    def render(self, context):
-        return u''
-
-@register.tag
-def autopaginate(parser, token):
-    return AutoPaginateNode()
-
-class PaginateNode(Node):
-    def render(self, context):
-        return u''
-
-@register.tag
-def paginate(parser, token):
-    return PaginateNode()
 # because of reload()'s, do "from postman.utils import notification" just before needs
 from postman.utils import format_body, format_subject
 
-if not 'pagination' in settings.INSTALLED_APPS:
-    try:
-        import postman.templatetags.pagination_tags
-    except:
-        sys.exit(
-            "Some templates need templatetags from the django-pagination application.\n"
-            "Add it to the INSTALLED_APPS, or allow a mock by renaming\n"
-            "postman/templatetags/pagination_tags_for_tests.py to pagination_tags.py"
-        )
-
 class GenericTest(TestCase):
     """
     Usual generic tests.