diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 12446836a..9032746d8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,8 +34,8 @@ jobs: fail-fast: false matrix: db: [sqlite, postgres, mysql] - python-version: [3.7, 3.8, 3.9] - django-version: [2.2] + python-version: [3.9, 3.10] + django-version: [3.2] include: - db: sqlite db_url: sqlite:///test_db.sqlite3 diff --git a/demo/demo_widgets/models.py b/demo/demo_widgets/models.py index 3921b1ab2..3649b6901 100644 --- a/demo/demo_widgets/models.py +++ b/demo/demo_widgets/models.py @@ -1,6 +1,5 @@ from django.db import models -from django.utils.translation import ugettext_lazy as _ -from django.utils.encoding import python_2_unicode_compatible +from django.utils.translation import gettext_lazy as _ import widgy from widgy.models import Content @@ -16,7 +15,6 @@ def valid_parent_of(self, cls, obj=None): @widgy.register -@python_2_unicode_compatible class Slide(StrDisplayNameMixin, AcceptsSimpleHtmlChildrenMixin, Content): tagline = models.CharField(_('tagline'), max_length=255) background_image = ImageField(verbose_name=_('background image')) @@ -42,7 +40,6 @@ def valid_parent_of(self, cls, obj=None): @widgy.register -@python_2_unicode_compatible class Box(StrDisplayNameMixin, AcceptsSimpleHtmlChildrenMixin, Content): title = models.CharField(verbose_name=_('title'), max_length=255) diff --git a/demo/templates/base.html b/demo/templates/base.html index b9564a9a7..fe2d50b10 100644 --- a/demo/templates/base.html +++ b/demo/templates/base.html @@ -2,7 +2,7 @@ {% load compress %} {% load pages_tags %} {% load widgy_tags %} -{% load staticfiles %} +{% load static %}
diff --git a/setup.py b/setup.py index 6d282862e..a7a75fb60 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ def read(fname): 'django-compressor>=1.3', 'beautifulsoup4', 'django-argonauts>=1.1.4', - 'Django~=2.2', + 'Django>=3.1,<3.3', 'html5lib', 'bleach', 'bleach-whitelist', diff --git a/tests/core_tests/models.py b/tests/core_tests/models.py index d333d7b12..b364a822a 100644 --- a/tests/core_tests/models.py +++ b/tests/core_tests/models.py @@ -2,12 +2,11 @@ from __future__ import unicode_literals from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from widgy.models import Content from widgy.db.fields import WidgyField, VersionedWidgyField from widgy import registry -from django.utils.encoding import python_2_unicode_compatible from widgy.models import links from widgy.models.mixins import InvisibleMixin @@ -42,7 +41,6 @@ class Meta: verbose_name = _("bucket") -@python_2_unicode_compatible class RawTextWidget(Content): text = models.TextField() @@ -212,7 +210,6 @@ class ForeignKeyWidget(Content): @links.register -@python_2_unicode_compatible class LinkableThing(models.Model): name = models.CharField(max_length=255, default='') diff --git a/tests/core_tests/tests/test_api.py b/tests/core_tests/tests/test_api.py index ac781390d..3f10589c5 100644 --- a/tests/core_tests/tests/test_api.py +++ b/tests/core_tests/tests/test_api.py @@ -4,7 +4,7 @@ import json import imp -import mock +from unittest import mock from django import urls from django.utils.functional import cached_property diff --git a/tests/core_tests/tests/test_core.py b/tests/core_tests/tests/test_core.py index a9b19708f..1d006881e 100644 --- a/tests/core_tests/tests/test_core.py +++ b/tests/core_tests/tests/test_core.py @@ -4,7 +4,7 @@ from pprint import pprint import datetime import time -import mock +from unittest import mock import unittest import contextlib diff --git a/tests/core_tests/tests/test_fields.py b/tests/core_tests/tests/test_fields.py index 9c88c0ea8..e3f4aff9e 100644 --- a/tests/core_tests/tests/test_fields.py +++ b/tests/core_tests/tests/test_fields.py @@ -7,7 +7,7 @@ from django.contrib.contenttypes.models import ContentType from django.template import Context -import mock +from unittest import mock from widgy.forms import WidgyFormMixin, WidgyFormField from widgy.models import Node, VersionTracker diff --git a/widgy/contrib/form_builder/admin.py b/widgy/contrib/form_builder/admin.py index 93300e664..cc2d8a06d 100644 --- a/widgy/contrib/form_builder/admin.py +++ b/widgy/contrib/form_builder/admin.py @@ -3,7 +3,7 @@ from django.urls import reverse from django.http import HttpResponse from django.shortcuts import render -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.conf.urls import url from django.template.defaultfilters import slugify from django.http import Http404 diff --git a/widgy/contrib/form_builder/models.py b/widgy/contrib/form_builder/models.py index 3d22a2682..8155eb6a5 100644 --- a/widgy/contrib/form_builder/models.py +++ b/widgy/contrib/form_builder/models.py @@ -14,12 +14,12 @@ from django import forms from django.core.mail import EmailMultiAlternatives from django.conf import settings -from django.utils.translation import ugettext_lazy as _, ugettext +from django.utils.translation import gettext_lazy as _, gettext from django.shortcuts import redirect from django.dispatch import receiver from django.template.loader import render_to_string from django.utils.functional import cached_property -from django.utils.encoding import python_2_unicode_compatible, force_bytes, force_text +from django.utils.encoding import force_bytes, force_text from django.template.defaultfilters import truncatechars from django.core.files import File from django.core.files.storage import default_storage @@ -154,7 +154,6 @@ def __init__(self, *args, **kwargs): @widgy.register -@python_2_unicode_compatible class FieldMappingValue(StrDisplayNameMixin, MappingValue): """ MappingValue that maps a form field to another value. @@ -222,7 +221,6 @@ class EmailSuccessHandlerBaseForm(forms.ModelForm): content = CKEditorField() -@python_2_unicode_compatible class EmailSuccessHandlerBase(StrDisplayNameMixin, FormSuccessHandler): subject = models.CharField(max_length=255, verbose_name=_('subject')) content = models.TextField(blank=True, verbose_name=_('content')) @@ -345,7 +343,6 @@ def post_create(self, site): @widgy.register -@python_2_unicode_compatible class SubmitButton(StrDisplayNameMixin, FormElement): text = models.CharField(max_length=255, default=_('submit'), verbose_name=_('text')) @@ -364,7 +361,7 @@ def __str__(self): def untitled_form(): - untitled = ugettext('Untitled form') + untitled = gettext('Untitled form') n = Form.objects.filter(name__startswith=untitled + ' ').exclude( _nodes__is_frozen=True ).count() + 1 @@ -457,7 +454,6 @@ def friendly_uuid(uuid): @widgy.register -@python_2_unicode_compatible class Form(TabbedContainer, StrDisplayNameMixin, StrictDefaultChildrenMixin, Content): name = models.CharField(verbose_name=_('Name'), max_length=255, @@ -668,7 +664,6 @@ class FormFieldForm(forms.ModelForm): help_text = MiniCKEditorField(label=_('help text'), required=False) -@python_2_unicode_compatible class FormField(StrDisplayNameMixin, BaseFormField): widget = None @@ -978,7 +973,7 @@ def get_formfield_labels(self): ).values('field_ident').distinct().order_by('field_node__path').values_list('field_ident', flat=True) ret = OrderedDict([ - ('created_at', ugettext('Created at')), + ('created_at', gettext('Created at')), ]) for field_uuid in uuids: latest_value = FormValue.objects.filter( diff --git a/widgy/contrib/form_builder/tests.py b/widgy/contrib/form_builder/tests.py index 6289a8a00..4ae7ab9e2 100644 --- a/widgy/contrib/form_builder/tests.py +++ b/widgy/contrib/form_builder/tests.py @@ -18,7 +18,7 @@ from django.core.files.uploadedfile import TemporaryUploadedFile from django.conf import settings -import mock +from unittest import mock from widgy.contrib.form_builder.forms import PhoneNumberField from widgy.contrib.form_builder.models import ( diff --git a/widgy/contrib/page_builder/db/fields.py b/widgy/contrib/page_builder/db/fields.py index fe6ce419c..bce077737 100644 --- a/widgy/contrib/page_builder/db/fields.py +++ b/widgy/contrib/page_builder/db/fields.py @@ -6,7 +6,7 @@ from django import forms from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from filer.fields.file import FilerFileField from filer.models.filemodels import File @@ -79,7 +79,7 @@ def __init__(self, *args, **kwargs): super(VideoField, self).__init__(*args, **kwargs) self.validators.append(validators_video_url) - def from_db_value(self, value, expression, connection, context): + def from_db_value(self, value, expression, connection): if value is None: return value return self.get_url_instance(value) diff --git a/widgy/contrib/page_builder/models.py b/widgy/contrib/page_builder/models.py index 18184e368..dd90aa1ff 100644 --- a/widgy/contrib/page_builder/models.py +++ b/widgy/contrib/page_builder/models.py @@ -1,7 +1,7 @@ from django import forms from django.db import models from django.conf import settings -from django.utils.translation import ugettext_lazy as _, ugettext +from django.utils.translation import gettext_lazy as _ from django.dispatch import receiver from django.template.defaultfilters import truncatechars from django.contrib.sites.models import Site diff --git a/widgy/contrib/review_queue/admin.py b/widgy/contrib/review_queue/admin.py index 4eb52f4ad..e5dfd1921 100644 --- a/widgy/contrib/review_queue/admin.py +++ b/widgy/contrib/review_queue/admin.py @@ -3,7 +3,7 @@ from django.contrib.admin import ModelAdmin from django.contrib.admin.views.main import ChangeList from django.contrib import messages -from django.utils.translation import ugettext_lazy as _, ungettext +from django.utils.translation import gettext_lazy as _, ungettext from django.utils.html import format_html from django.template.loader import render_to_string from django.utils.safestring import mark_safe diff --git a/widgy/contrib/review_queue/models.py b/widgy/contrib/review_queue/models.py index 926d92714..0e8fdb009 100644 --- a/widgy/contrib/review_queue/models.py +++ b/widgy/contrib/review_queue/models.py @@ -1,6 +1,6 @@ from django.db import models from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.conf import settings from widgy.utils import QuerySet diff --git a/widgy/contrib/review_queue/templates/review_queue/commit_preview.html b/widgy/contrib/review_queue/templates/review_queue/commit_preview.html index d81089bd6..2bcbe7016 100644 --- a/widgy/contrib/review_queue/templates/review_queue/commit_preview.html +++ b/widgy/contrib/review_queue/templates/review_queue/commit_preview.html @@ -1,4 +1,4 @@ -{% load compress staticfiles widgy_tags %} +{% load compress static widgy_tags %} {% for owner in owners %} {% get_action_links owner node as links %} {% for link in links %} diff --git a/widgy/contrib/review_queue/views.py b/widgy/contrib/review_queue/views.py index 2a3c282c9..5842cb1fb 100644 --- a/widgy/contrib/review_queue/views.py +++ b/widgy/contrib/review_queue/views.py @@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404, redirect from django.contrib import messages -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.utils.http import is_safe_url from django.utils.html import format_html from django.views.generic import RedirectView, FormView diff --git a/widgy/contrib/urlconf_include/middleware.py b/widgy/contrib/urlconf_include/middleware.py index 66abff71d..5e6ac4ca2 100644 --- a/widgy/contrib/urlconf_include/middleware.py +++ b/widgy/contrib/urlconf_include/middleware.py @@ -7,11 +7,12 @@ from django.conf.urls import include, url from django.conf.urls.i18n import i18n_patterns from django import urls +from django.utils.deprecation import MiddlewareMixin from .models import UrlconfIncludePage -class PatchUrlconfMiddleware(object): +class PatchUrlconfMiddleware(MiddlewareMixin): def process_request(self, request): root_urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF) if isinstance(root_urlconf, six.string_types): diff --git a/widgy/contrib/urlconf_include/models.py b/widgy/contrib/urlconf_include/models.py index fc0b25844..d8a88b477 100644 --- a/widgy/contrib/urlconf_include/models.py +++ b/widgy/contrib/urlconf_include/models.py @@ -1,6 +1,6 @@ from django.db import models from django.core.exceptions import ImproperlyConfigured -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.conf import settings from mezzanine.pages.models import Page diff --git a/widgy/contrib/urlconf_include/tests.py b/widgy/contrib/urlconf_include/tests.py index c5ef1c6a4..e2d522aba 100644 --- a/widgy/contrib/urlconf_include/tests.py +++ b/widgy/contrib/urlconf_include/tests.py @@ -6,6 +6,7 @@ from django.utils.decorators import decorator_from_middleware from django.http import HttpResponse, HttpResponseNotFound from django import urls +from django.urls.resolvers import _get_cached_resolver from django.contrib.auth.models import AnonymousUser from django.contrib.auth import get_user_model from django.conf.urls import include, url @@ -57,12 +58,8 @@ class TestMiddleware(TestCase): def setUp(self): self.factory = RequestFactory() - if django.VERSION > (1, 7): - def resolver_cache_size(self): - return urls.get_resolver.cache_info().currsize - else: - def resolver_cache_size(self): - return len(urls._resolver_cache) + def resolver_cache_size(self): + return _get_cached_resolver.cache_info().currsize def get_request(self, path='/'): r = self.factory.get(path) diff --git a/widgy/contrib/widgy_i18n/models.py b/widgy/contrib/widgy_i18n/models.py index 6dc4b992d..e9cbd5be9 100644 --- a/widgy/contrib/widgy_i18n/models.py +++ b/widgy/contrib/widgy_i18n/models.py @@ -1,6 +1,6 @@ from django.db import models from django.utils.translation import ( - ugettext_lazy as _, ugettext, get_language, get_language_info + gettext_lazy as _, gettext, get_language, get_language_info ) from django.conf import settings @@ -25,7 +25,7 @@ class Meta: @property def language_name(self): info = get_language_info(self.language_code) - return ugettext(info['name']) + return gettext(info['name']) @property def display_name(self): diff --git a/widgy/contrib/widgy_mezzanine/admin.py b/widgy/contrib/widgy_mezzanine/admin.py index 9fd1ed004..5ed333fe4 100644 --- a/widgy/contrib/widgy_mezzanine/admin.py +++ b/widgy/contrib/widgy_mezzanine/admin.py @@ -6,7 +6,7 @@ from django import forms from django.urls import reverse from django.contrib.admin.utils import quote -from django.utils.translation import ugettext_lazy as _, ugettext, ungettext +from django.utils.translation import gettext_lazy as _, gettext, ungettext from django.utils.html import format_html from django.utils import timezone from django.contrib import messages @@ -235,7 +235,7 @@ def get_undelete_queryset(self, layouts): def label_from_instance(self, obj): url = reverse('widgy.contrib.widgy_mezzanine.views.preview', kwargs={'node_pk': obj.working_copy.pk}) - return format_html('{preview}', url=url, preview=ugettext('preview')) + return format_html('{preview}', url=url, preview=gettext('preview')) class UndeletePageAdminMixin(object): diff --git a/widgy/contrib/widgy_mezzanine/models.py b/widgy/contrib/widgy_mezzanine/models.py index 5bfbbe13e..ed4ac3d75 100644 --- a/widgy/contrib/widgy_mezzanine/models.py +++ b/widgy/contrib/widgy_mezzanine/models.py @@ -1,5 +1,5 @@ from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.utils.encoding import force_text from django.conf import settings from django import urls diff --git a/widgy/contrib/widgy_mezzanine/templates/pages/widgypage_base.html b/widgy/contrib/widgy_mezzanine/templates/pages/widgypage_base.html index f8cd88551..c800e4001 100644 --- a/widgy/contrib/widgy_mezzanine/templates/pages/widgypage_base.html +++ b/widgy/contrib/widgy_mezzanine/templates/pages/widgypage_base.html @@ -10,7 +10,7 @@ {% load widgy_tags %} {% load pages_tags %} {% load compress %} -{% load staticfiles %} +{% load static %} {% block title %}{{ page.meta_title }} {{ block.super }}{% endblock %} {% block css %} diff --git a/widgy/contrib/widgy_mezzanine/templates/widgy/widgy_mezzanine/versioned_widgy_field.html b/widgy/contrib/widgy_mezzanine/templates/widgy/widgy_mezzanine/versioned_widgy_field.html index 8e3c69520..3bfa42a56 100644 --- a/widgy/contrib/widgy_mezzanine/templates/widgy/widgy_mezzanine/versioned_widgy_field.html +++ b/widgy/contrib/widgy_mezzanine/templates/widgy/widgy_mezzanine/versioned_widgy_field.html @@ -1,6 +1,6 @@ {% extends "widgy/versioned_widgy_field_base.html" %} {% load i18n %} -{% load staticfiles %} +{% load static %} {% block widgy_tools %}