From: Radek Czajka Date: Fri, 22 Jul 2022 14:18:34 +0000 (+0200) Subject: Support Django 4.0, drop Django < 2.1, Python < 3.6. X-Git-Tag: 2.2.5 X-Git-Url: https://git.mdrn.pl/django-pagination.git/commitdiff_plain/bb6b9042d8950e58322dc66497678c5fdb150a4f?ds=sidebyside Support Django 4.0, drop Django < 2.1, Python < 3.6. --- diff --git a/fnp_django_pagination/__init__.py b/fnp_django_pagination/__init__.py index fe60da6..0bbc19b 100644 --- a/fnp_django_pagination/__init__.py +++ b/fnp_django_pagination/__init__.py @@ -34,4 +34,4 @@ tools throughout a django application. """ -__version__ = (2, 2, 4, "final", 0) +__version__ = (2, 2, 5, "final", 0) diff --git a/fnp_django_pagination/middleware.py b/fnp_django_pagination/middleware.py index 4036511..9d2d9f4 100644 --- a/fnp_django_pagination/middleware.py +++ b/fnp_django_pagination/middleware.py @@ -28,11 +28,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -try: - from django.utils.deprecation import MiddlewareMixin -except ImportError: - # Django < 1.10 - MiddlewareMixin = object +from django.utils.deprecation import MiddlewareMixin def get_page(self, suffix=''): @@ -41,7 +37,6 @@ def get_page(self, suffix=''): integer representing the current page. """ try: - # REQUEST is deprecated as of Django 1.7. key = 'page%s' % suffix value = self.POST.get(key) if value is None: diff --git a/fnp_django_pagination/templates/pagination/pagination.html b/fnp_django_pagination/templates/pagination/pagination.html index ea01b61..8ab929f 100644 --- a/fnp_django_pagination/templates/pagination/pagination.html +++ b/fnp_django_pagination/templates/pagination/pagination.html @@ -18,7 +18,7 @@ {% if display_page_links %} {% for page in pages %} {% if page %} - {% ifequal page page_obj.number %} + {% if page == page_obj.number %} {{ page }} {% else %} {% if disable_link_for_first_page and page == 1 %} @@ -26,7 +26,7 @@ {% else %} {{ page }} {% endif %} - {% endifequal %} + {% endif %} {% else %} ... {% endif %} diff --git a/fnp_django_pagination/templatetags/pagination_tags.py b/fnp_django_pagination/templatetags/pagination_tags.py index 3802a47..015e19c 100644 --- a/fnp_django_pagination/templatetags/pagination_tags.py +++ b/fnp_django_pagination/templatetags/pagination_tags.py @@ -42,15 +42,8 @@ from django.template import ( loader, ) -try: - from django.template.base import TokenType - TOKEN_BLOCK = TokenType.BLOCK -except ImportError: - try: - # Django 1.8-1.11 - from django.template.base import TOKEN_BLOCK - except ImportError: # Django < 1.8 - from django.template import TOKEN_BLOCK +from django.template.base import TokenType +TOKEN_BLOCK = TokenType.BLOCK from django.template.loader import select_template from django.utils.text import unescape_string_literal diff --git a/fnp_django_pagination/tests/runner.py b/fnp_django_pagination/tests/runner.py index 843a5a5..4604e6b 100755 --- a/fnp_django_pagination/tests/runner.py +++ b/fnp_django_pagination/tests/runner.py @@ -9,11 +9,7 @@ from django.core.management import call_command def runtests(): os.environ['DJANGO_SETTINGS_MODULE'] = 'fnp_django_pagination.tests.settings' - - try: - django.setup() - except AttributeError: # for Django 1.6 compatible - pass + django.setup() failures = call_command('test', 'fnp_django_pagination') sys.exit(bool(failures)) diff --git a/fnp_django_pagination/tests/test_main.py b/fnp_django_pagination/tests/test_main.py index 8885c16..d6fe6cc 100644 --- a/fnp_django_pagination/tests/test_main.py +++ b/fnp_django_pagination/tests/test_main.py @@ -31,12 +31,7 @@ from django.core.paginator import Paginator from django.http import HttpRequest as DjangoHttpRequest from django.template import Template, Context - -try: - from django.test import SimpleTestCase -except ImportError: # Django 1.2 compatible - from django.test import TestCase as SimpleTestCase - +from django.test import SimpleTestCase from fnp_django_pagination.paginator import InfinitePaginator, FinitePaginator from fnp_django_pagination.templatetags.pagination_tags import paginate from fnp_django_pagination.middleware import PaginationMiddleware @@ -393,7 +388,7 @@ class MiddlewareTestCase(SimpleTestCase): Test middleware """ def test_get_page_in_request(self): - middleware = PaginationMiddleware() + middleware = PaginationMiddleware(lambda: None) request = DjangoHttpRequest() middleware.process_request(request) self.assertEqual(request.page(''), 1) diff --git a/tox.ini b/tox.ini index deea80a..84fee35 100644 --- a/tox.ini +++ b/tox.ini @@ -1,33 +1,21 @@ [tox] envlist=clear, - d{12,13,14,15,16,17,18}-py27, - d{19,110}-py{27,35}, - d111-py{27,35,36,37}, - d{20,21}-py{35,36,37}, - d22-py{35,36,37,38,39}, - d{30,31,32}-py{36,37,38,39} + d{21}-py{36,37}, + d{22,30,31,32}-py{36,37,38,39} + d32-py{36,37,38,39,310} + d40-py{38,39,310} stats [testenv] -indexserver=https://py.mdrn.pl:8443 commands=coverage run --source=fnp_django_pagination --omit *runner*,*test_project* setup.py test deps= - d12: Django>=1.2,<1.3 - d13: Django>=1.3,<1.4 - d14: Django>=1.4,<1.5 - d15: Django>=1.5,<1.6 - d16: Django>=1.6,<1.7 - d17: Django>=1.7,<1.8 - d18: Django>=1.8,<1.9 - d19: Django>=1.9,<1.10 - d110: Django>=1.10,<1.11 - d111: Django>=1.11,<2.0 d20: Django>=2.0,<2.1 d21: Django>=2.1,<2.2 d22: Django>=2.2,<3.0 d30: Django>=3.0,<3.1 d31: Django>=3.1,<3.2 d32: Django>=3.2,<4.0 + d40: Django>=4.0,<4.1 coverage [testenv:clear]