From fd9ea4a91126725c10c1d07547891b697a552a69 Mon Sep 17 00:00:00 2001 From: Patrick Samson Date: Sun, 25 Nov 2012 21:56:55 +0100 Subject: [PATCH] Remove the dependency to django-pagination in the default template set --- docs/faq.rst | 9 ++++-- docs/tags-filters.rst | 9 ++++-- postman/templates/postman/base_folder.html | 9 +++++- postman/templatetags/pagination_tags.py | 30 +++++++++++++++++++ .../templatetags/pagination_tags_for_tests.py | 27 ----------------- postman/tests.py | 10 ------- 6 files changed, 51 insertions(+), 43 deletions(-) create mode 100644 postman/templatetags/pagination_tags.py delete mode 100644 postman/templatetags/pagination_tags_for_tests.py diff --git a/docs/faq.rst b/docs/faq.rst index bab1fe0..4afcde0 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -6,6 +6,11 @@ General **I don't want to bother with the moderation feature, how to bypass it?** Set the configuration option:: - + POSTMAN_AUTO_MODERATE_AS = True - \ No newline at end of file + +**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). diff --git a/docs/tags-filters.rst b/docs/tags-filters.rst index d4a8a3f..664b70b 100644 --- a/docs/tags-filters.rst +++ b/docs/tags-filters.rst @@ -11,9 +11,12 @@ that are not intended for your site design: * :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 ---- diff --git a/postman/templates/postman/base_folder.html b/postman/templates/postman/base_folder.html index 10a2da4..f0ab833 100644 --- a/postman/templates/postman/base_folder.html +++ b/postman/templates/postman/base_folder.html @@ -1,6 +1,13 @@ {% 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 %}

{% block pm_folder_title %}{% endblock %}

diff --git a/postman/templatetags/pagination_tags.py b/postman/templatetags/pagination_tags.py new file mode 100644 index 0000000..4b8f957 --- /dev/null +++ b/postman/templatetags/pagination_tags.py @@ -0,0 +1,30 @@ +""" +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() diff --git a/postman/templatetags/pagination_tags_for_tests.py b/postman/templatetags/pagination_tags_for_tests.py deleted file mode 100644 index 014d8a3..0000000 --- a/postman/templatetags/pagination_tags_for_tests.py +++ /dev/null @@ -1,27 +0,0 @@ -""" -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() diff --git a/postman/tests.py b/postman/tests.py index 0a535dc..b0449c1 100644 --- a/postman/tests.py +++ b/postman/tests.py @@ -61,16 +61,6 @@ from postman.urls import OPTION_MESSAGES # 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. -- 2.39.5