From 12fa5deb8220b12e21b44524751cc515796bf219 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Markus=20T=C3=B6rnqvist?= Date: Wed, 26 Jun 2013 15:38:05 +0300 Subject: [PATCH 01/16] Context is updated, return it. Also avoid recursion error. --- linaro_django_pagination/templatetags/pagination_tags.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/linaro_django_pagination/templatetags/pagination_tags.py b/linaro_django_pagination/templatetags/pagination_tags.py index a4e4fed..1577452 100644 --- a/linaro_django_pagination/templatetags/pagination_tags.py +++ b/linaro_django_pagination/templatetags/pagination_tags.py @@ -186,7 +186,7 @@ class PaginateNode(Node): new_context = paginate(context) if self.template: template_list.insert(0, self.template) - return loader.render_to_string(template_list, new_context, + return loader.render_to_string(template_list, new_context, context_instance = context) @@ -326,12 +326,11 @@ def paginate(context, window=DEFAULT_WINDOW, margin=DEFAULT_MARGIN): new_context['getvars'] = "&%s" % getvars.urlencode() else: new_context['getvars'] = '' - except (KeyError, AttributeError): - new_context = {} - context.update(new_context) + context.update(new_context) - return context + except (KeyError, AttributeError): + pass register = Library() -- 2.20.1 From f98500a281c62525076d87e98435c586ff5f87e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Markus=20T=C3=B6rnqvist?= Date: Wed, 26 Jun 2013 15:56:53 +0300 Subject: [PATCH 02/16] Revert "Context is updated, return it. Also avoid recursion error." This reverts commit 12fa5deb8220b12e21b44524751cc515796bf219. --- linaro_django_pagination/templatetags/pagination_tags.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/linaro_django_pagination/templatetags/pagination_tags.py b/linaro_django_pagination/templatetags/pagination_tags.py index 1577452..a4e4fed 100644 --- a/linaro_django_pagination/templatetags/pagination_tags.py +++ b/linaro_django_pagination/templatetags/pagination_tags.py @@ -186,7 +186,7 @@ class PaginateNode(Node): new_context = paginate(context) if self.template: template_list.insert(0, self.template) - return loader.render_to_string(template_list, new_context, + return loader.render_to_string(template_list, new_context, context_instance = context) @@ -326,11 +326,12 @@ def paginate(context, window=DEFAULT_WINDOW, margin=DEFAULT_MARGIN): new_context['getvars'] = "&%s" % getvars.urlencode() else: new_context['getvars'] = '' + except (KeyError, AttributeError): + new_context = {} - context.update(new_context) + context.update(new_context) - except (KeyError, AttributeError): - pass + return context register = Library() -- 2.20.1 From ee4a0ff91a1567ccabdb5eb0d8ff07aad6ffd486 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Markus=20T=C3=B6rnqvist?= Date: Wed, 26 Jun 2013 15:57:10 +0300 Subject: [PATCH 03/16] Revert "Oops, do not return new_context just yet, update and then return" This reverts commit 73848ab99035e9b6d0bb6cf2f0483d70aac22b62. --- linaro_django_pagination/templatetags/pagination_tags.py | 1 + 1 file changed, 1 insertion(+) diff --git a/linaro_django_pagination/templatetags/pagination_tags.py b/linaro_django_pagination/templatetags/pagination_tags.py index a4e4fed..be22347 100644 --- a/linaro_django_pagination/templatetags/pagination_tags.py +++ b/linaro_django_pagination/templatetags/pagination_tags.py @@ -326,6 +326,7 @@ def paginate(context, window=DEFAULT_WINDOW, margin=DEFAULT_MARGIN): new_context['getvars'] = "&%s" % getvars.urlencode() else: new_context['getvars'] = '' + return new_context except (KeyError, AttributeError): new_context = {} -- 2.20.1 From 85fccdadc5fcde0071721942395bd515ea9eed03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Markus=20T=C3=B6rnqvist?= Date: Wed, 26 Jun 2013 16:02:56 +0300 Subject: [PATCH 04/16] Skip updating empty dict over context --- linaro_django_pagination/templatetags/pagination_tags.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/linaro_django_pagination/templatetags/pagination_tags.py b/linaro_django_pagination/templatetags/pagination_tags.py index be22347..affdc16 100644 --- a/linaro_django_pagination/templatetags/pagination_tags.py +++ b/linaro_django_pagination/templatetags/pagination_tags.py @@ -186,7 +186,7 @@ class PaginateNode(Node): new_context = paginate(context) if self.template: template_list.insert(0, self.template) - return loader.render_to_string(template_list, new_context, + return loader.render_to_string(template_list, new_context, context_instance = context) @@ -328,9 +328,7 @@ def paginate(context, window=DEFAULT_WINDOW, margin=DEFAULT_MARGIN): new_context['getvars'] = '' return new_context except (KeyError, AttributeError): - new_context = {} - - context.update(new_context) + pass return context -- 2.20.1 From b766da81c618de8137c6d418c2cccba9436aa208 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Markus=20T=C3=B6rnqvist?= Date: Thu, 11 Jul 2013 16:00:11 +0300 Subject: [PATCH 05/16] Finnish locale --- .../locale/fi/LC_MESSAGES/django.po | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 linaro_django_pagination/locale/fi/LC_MESSAGES/django.po diff --git a/linaro_django_pagination/locale/fi/LC_MESSAGES/django.po b/linaro_django_pagination/locale/fi/LC_MESSAGES/django.po new file mode 100644 index 0000000..a0bdb27 --- /dev/null +++ b/linaro_django_pagination/locale/fi/LC_MESSAGES/django.po @@ -0,0 +1,29 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-07-11 12:51+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: templates/pagination/pagination.html:6 +#: templates/pagination/pagination.html:9 +msgid "previous" +msgstr "edellinen" + +#: templates/pagination/pagination.html:30 +#: templates/pagination/pagination.html:33 +msgid "next" +msgstr "seuraava" -- 2.20.1 From 0b4a8b2e6f6881e26441f6a501718b63debd4a61 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 13 Jan 2014 19:55:46 -0500 Subject: [PATCH 06/16] Support Python 3.3 I went for the minimal option and tried to preserve the previous logic as much as possible. I target Python 3.3 so that I don't have to touch the u'' strings. --- .../templatetags/pagination_tags.py | 14 +++++++------- setup.py | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/linaro_django_pagination/templatetags/pagination_tags.py b/linaro_django_pagination/templatetags/pagination_tags.py index affdc16..a703928 100644 --- a/linaro_django_pagination/templatetags/pagination_tags.py +++ b/linaro_django_pagination/templatetags/pagination_tags.py @@ -60,7 +60,7 @@ def do_autopaginate(parser, token): # Check whether there are any other autopaginations are later in this template expr = lambda obj: (obj.token_type == TOKEN_BLOCK and \ len(obj.split_contents()) > 0 and obj.split_contents()[0] == "autopaginate") - multiple_paginations = len(filter(expr, parser.tokens)) > 0 + multiple_paginations = len([tok for tok in parser.tokens if expr(tok)]) > 0 i = iter(token.split_contents()) paginate_by = None @@ -69,26 +69,26 @@ def do_autopaginate(parser, token): orphans = None word = None try: - word = i.next() + word = next(i) assert word == "autopaginate" - queryset_var = i.next() - word = i.next() + queryset_var = next(i) + word = next(i) if word != "as": paginate_by = word try: paginate_by = int(paginate_by) except ValueError: pass - word = i.next() + word = next(i) if word != "as": orphans = word try: orphans = int(orphans) except ValueError: pass - word = i.next() + word = next(i) assert word == "as" - context_var = i.next() + context_var = next(i) except StopIteration: pass if queryset_var is None: diff --git a/setup.py b/setup.py index a3acd63..2686bd8 100755 --- a/setup.py +++ b/setup.py @@ -54,6 +54,8 @@ setup( "Operating System :: OS Independent", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.3", ], install_requires=[ 'django >= 1.2', -- 2.20.1 From 4b2ba62948c5104fc3cae8d24face3c4bf7378df Mon Sep 17 00:00:00 2001 From: Mike TUMS Date: Mon, 7 Apr 2014 12:35:33 +0400 Subject: [PATCH 07/16] Implements zyga/django-pagination#22 --- doc/usage.rst | 4 ++++ linaro_django_pagination/settings.py | 2 ++ .../templates/pagination/pagination.html | 10 +++++++++- .../templatetags/pagination_tags.py | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/usage.rst b/doc/usage.rst index a57cf46..199e6a3 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -168,3 +168,7 @@ behavior of the pagination tags. Here's an overview: ``PAGINATION_DISPLAY_DISABLED_NEXT_LINK`` If set to ``False``, the next page link will not be displayed if there's no next page. Defaults to False. + +``PAGINATION_DISABLE_LINK_FOR_FIRST_PAGE`` + if set to ``False``, the first page will have ``?page=1`` link suffix in pagination displayed, otherwise is omitted. + Defaults to True. diff --git a/linaro_django_pagination/settings.py b/linaro_django_pagination/settings.py index ff74fd3..24a04e0 100644 --- a/linaro_django_pagination/settings.py +++ b/linaro_django_pagination/settings.py @@ -52,3 +52,5 @@ DISPLAY_DISABLED_PREVIOUS_LINK = getattr( settings, 'PAGINATION_DISPLAY_DISABLED_PREVIOUS_LINK', False) DISPLAY_DISABLED_NEXT_LINK = getattr( settings, 'PAGINATION_DISPLAY_DISABLED_NEXT_LINK', False) +DISABLE_LINK_FOR_FIRST_PAGE = getattr( + settings, 'PAGINATION_DISABLE_LINK_FOR_FIRST_PAGE', True) diff --git a/linaro_django_pagination/templates/pagination/pagination.html b/linaro_django_pagination/templates/pagination/pagination.html index 1bd9ab5..5d926a3 100644 --- a/linaro_django_pagination/templates/pagination/pagination.html +++ b/linaro_django_pagination/templates/pagination/pagination.html @@ -3,7 +3,11 @@