diff --git a/requirements/tests.txt b/requirements/tests.txt index 522b1b2..c425c50 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,3 +1,6 @@ +django>=2.2.16,<3.0 +URLObject +django-appconf docutils model_mommy django-ttag>=2.3 diff --git a/setup.py b/setup.py index fe03807..911c7b3 100644 --- a/setup.py +++ b/setup.py @@ -37,16 +37,11 @@ def find_version(*file_paths): "Development Status :: 4 - Beta", 'Environment :: Web Environment', 'Framework :: Django', - 'Framework :: Django :: 1.9', - 'Framework :: Django :: 1.10', - 'Framework :: Django :: 1.11', + 'Framework :: Django :: 2.2', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2.5', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.8', 'Topic :: Utilities', ], install_requires=[ diff --git a/sorter/__init__.py b/sorter/__init__.py index 1878d2d..2930230 100644 --- a/sorter/__init__.py +++ b/sorter/__init__.py @@ -1 +1 @@ -__version__ = "0.3-caktus" +__version__ = "0.4-caktus" diff --git a/sorter/templatetags/sorter_tags.py b/sorter/templatetags/sorter_tags.py index 19b6642..a3668b0 100644 --- a/sorter/templatetags/sorter_tags.py +++ b/sorter/templatetags/sorter_tags.py @@ -32,7 +32,7 @@ def clean_with(self, value): """ Cleans the given name of the sort query """ - if not isinstance(value, basestring): + if not isinstance(value, str): raise TemplateSyntaxError("Value '%s' is not a string" % value) # in case the value equals the default query name # or it already has the default query name prefixed @@ -90,7 +90,7 @@ class TemplateAsTagMetaclass(ttag.helpers.as_tag.AsTagMetaclass): options_class = TemplateAsTagOptions -class SortURL(SorterAsTag): +class SortURL(SorterAsTag, metaclass=TemplateAsTagMetaclass): """ Parses a tag that's supposed to be in this format: @@ -99,8 +99,6 @@ class SortURL(SorterAsTag): {% sorturl with "objects" by "creation_date,-title" %} """ - __metaclass__ = TemplateAsTagMetaclass - with_ = ttag.Arg(required=False, named=True, default=settings.SORTER_DEFAULT_QUERY_NAME) rel = ttag.Arg(required=False, named=True) class_ = ttag.Arg(required=False, named=True) diff --git a/sorter/test_settings.py b/sorter/test_settings.py index 2f3a9f8..7ab490e 100644 --- a/sorter/test_settings.py +++ b/sorter/test_settings.py @@ -12,9 +12,16 @@ 'django.contrib.sites', 'django.contrib.auth', 'django.contrib.admin', + 'django.contrib.messages', 'sorter', ] +MIDDLEWARE = [ + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', +] + TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', @@ -22,6 +29,7 @@ 'OPTIONS': { 'context_processors': ( "django.contrib.auth.context_processors.auth", + 'django.contrib.messages.context_processors.messages' ), 'builtins': [ 'sorter.templatetags.sorter_tags', diff --git a/sorter/utils.py b/sorter/utils.py index 3ca7cc3..9ebc3c3 100644 --- a/sorter/utils.py +++ b/sorter/utils.py @@ -1,4 +1,4 @@ -from itertools import tee, izip, chain +from itertools import tee, chain def cycle_pairs(iterable): @@ -9,5 +9,5 @@ def cycle_pairs(iterable): """ first, last = iterable[0], iterable[-1] a, b = tee(iterable) - iter(b).next() - return chain(izip(a, b), [(last, first)]) + next(iter(b)) + return chain(zip(a, b), [(last, first)])