From a4bd82856c0986e9c299d8eb3df11fe2f5946580 Mon Sep 17 00:00:00 2001 From: Ed Rivas Date: Wed, 9 Sep 2020 17:24:45 -0600 Subject: [PATCH] feat: remove code deprecated in Django 3 --- mezzanine/conf/context_processors.py | 3 --- mezzanine/core/middleware.py | 3 ++- mezzanine/core/templates/admin/base_site.html | 2 +- mezzanine/core/templates/admin/index.html | 2 +- mezzanine/core/templates/admin/login.html | 2 +- mezzanine/core/templates/base.html | 2 +- mezzanine/core/templates/includes/editable_loader.html | 2 +- mezzanine/core/templates/includes/editable_toolbar.html | 2 +- mezzanine/forms/models.py | 2 -- mezzanine/forms/templates/admin/forms/entries.html | 2 +- mezzanine/galleries/models.py | 2 -- mezzanine/galleries/templates/pages/gallery.html | 2 +- mezzanine/generic/models.py | 2 -- mezzanine/pages/models.py | 2 -- mezzanine/pages/templates/admin/pages/page/change_list.html | 2 +- mezzanine/pages/templates/pages/menus/admin.html | 2 +- mezzanine/utils/cache.py | 2 +- mezzanine/utils/static.py | 2 +- 18 files changed, 14 insertions(+), 24 deletions(-) diff --git a/mezzanine/conf/context_processors.py b/mezzanine/conf/context_processors.py index f112266f93..95221dd2a6 100644 --- a/mezzanine/conf/context_processors.py +++ b/mezzanine/conf/context_processors.py @@ -1,13 +1,10 @@ from warnings import warn -from django.utils.encoding import python_2_unicode_compatible - # Deprecated settings and their defaults. DEPRECATED = {} -@python_2_unicode_compatible class TemplateSettings(dict): """ Dict wrapper for template settings. This exists to enforce diff --git a/mezzanine/core/middleware.py b/mezzanine/core/middleware.py index 8bdd503bd9..573e6d62f8 100755 --- a/mezzanine/core/middleware.py +++ b/mezzanine/core/middleware.py @@ -1,5 +1,7 @@ import warnings +from functools import lru_cache + from django.contrib import admin from django.contrib.auth import logout from django.contrib.messages import error @@ -15,7 +17,6 @@ from django.middleware.csrf import CsrfViewMiddleware, get_token from django.template import Template, RequestContext from django.utils.cache import get_max_age -from django.utils.lru_cache import lru_cache from django.utils.safestring import mark_safe from django.utils.translation import ugettext as _ diff --git a/mezzanine/core/templates/admin/base_site.html b/mezzanine/core/templates/admin/base_site.html index 00bb3cc036..8a59711ed1 100644 --- a/mezzanine/core/templates/admin/base_site.html +++ b/mezzanine/core/templates/admin/base_site.html @@ -1,5 +1,5 @@ {% extends "admin/base.html" %} -{% load mezzanine_tags i18n staticfiles static %} +{% load mezzanine_tags i18n static static %} {% block title %}{{ title }} | Mezzanine{% endblock %} diff --git a/mezzanine/core/templates/admin/index.html b/mezzanine/core/templates/admin/index.html index 22d2ca47a2..84e1c01119 100644 --- a/mezzanine/core/templates/admin/index.html +++ b/mezzanine/core/templates/admin/index.html @@ -1,6 +1,6 @@ {% extends "admin/base_site.html" %} -{% load i18n mezzanine_tags staticfiles %} +{% load i18n mezzanine_tags static %} {% block extrahead %} {{ block.super }} diff --git a/mezzanine/core/templates/admin/login.html b/mezzanine/core/templates/admin/login.html index e362f8aebd..fb51c20f81 100644 --- a/mezzanine/core/templates/admin/login.html +++ b/mezzanine/core/templates/admin/login.html @@ -1,5 +1,5 @@ {% extends "admin/base_site.html" %} -{% load i18n staticfiles %} +{% load i18n static %} {% block extrahead %} diff --git a/mezzanine/core/templates/base.html b/mezzanine/core/templates/base.html index f7d78da064..571766210c 100644 --- a/mezzanine/core/templates/base.html +++ b/mezzanine/core/templates/base.html @@ -1,6 +1,6 @@ -{% load pages_tags mezzanine_tags i18n staticfiles %} +{% load pages_tags mezzanine_tags i18n static %} diff --git a/mezzanine/core/templates/includes/editable_loader.html b/mezzanine/core/templates/includes/editable_loader.html index df79ffe771..1d5db0ab84 100644 --- a/mezzanine/core/templates/includes/editable_loader.html +++ b/mezzanine/core/templates/includes/editable_loader.html @@ -1,4 +1,4 @@ -{% load i18n staticfiles %} +{% load i18n static %} {% if has_site_permission %} diff --git a/mezzanine/core/templates/includes/editable_toolbar.html b/mezzanine/core/templates/includes/editable_toolbar.html index 3c1ab90716..e4f03da6d9 100644 --- a/mezzanine/core/templates/includes/editable_toolbar.html +++ b/mezzanine/core/templates/includes/editable_toolbar.html @@ -1,4 +1,4 @@ -{% load i18n staticfiles %} +{% load i18n static %}
{% url "admin:index" as admin_index_url %} diff --git a/mezzanine/forms/models.py b/mezzanine/forms/models.py index f7b4e9d6ef..508e25fb43 100644 --- a/mezzanine/forms/models.py +++ b/mezzanine/forms/models.py @@ -1,5 +1,4 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ from mezzanine.conf import settings @@ -65,7 +64,6 @@ def visible(self): return self.filter(visible=True) -@python_2_unicode_compatible class AbstractBaseField(Orderable): """ A field for a user-built form. diff --git a/mezzanine/forms/templates/admin/forms/entries.html b/mezzanine/forms/templates/admin/forms/entries.html index 2926a8b4eb..b4bb47250f 100644 --- a/mezzanine/forms/templates/admin/forms/entries.html +++ b/mezzanine/forms/templates/admin/forms/entries.html @@ -1,6 +1,6 @@ {% extends "admin/base_site.html" %} -{% load i18n staticfiles %} +{% load i18n static %} {% block extrahead %} {{ block.super }} diff --git a/mezzanine/galleries/models.py b/mezzanine/galleries/models.py index f7f0e62042..0779d3c21f 100644 --- a/mezzanine/galleries/models.py +++ b/mezzanine/galleries/models.py @@ -7,7 +7,6 @@ from django.core.files.base import ContentFile from django.core.files.storage import default_storage from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ @@ -127,7 +126,6 @@ class Meta: verbose_name_plural = _("Galleries") -@python_2_unicode_compatible class GalleryImage(Orderable): gallery = models.ForeignKey( diff --git a/mezzanine/galleries/templates/pages/gallery.html b/mezzanine/galleries/templates/pages/gallery.html index 90c78cd230..42aa56a443 100644 --- a/mezzanine/galleries/templates/pages/gallery.html +++ b/mezzanine/galleries/templates/pages/gallery.html @@ -1,6 +1,6 @@ {% extends "pages/page.html" %} -{% load mezzanine_tags staticfiles %} +{% load mezzanine_tags static %} {% block extra_css %} diff --git a/mezzanine/generic/models.py b/mezzanine/generic/models.py index 9b87159bc8..45847eefed 100644 --- a/mezzanine/generic/models.py +++ b/mezzanine/generic/models.py @@ -2,7 +2,6 @@ from django.db import models from django.template.defaultfilters import truncatewords_html from django.utils.translation import ugettext, ugettext_lazy as _ -from django.utils.encoding import python_2_unicode_compatible from django.utils.html import format_html from django_comments.models import Comment @@ -108,7 +107,6 @@ class Meta: verbose_name_plural = _("Keywords") -@python_2_unicode_compatible class AssignedKeyword(Orderable): """ A ``Keyword`` assigned to a model instance. diff --git a/mezzanine/pages/models.py b/mezzanine/pages/models.py index 9cd347b80f..2a2e3bb88d 100644 --- a/mezzanine/pages/models.py +++ b/mezzanine/pages/models.py @@ -4,7 +4,6 @@ from django.urls import resolve, reverse from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _, ugettext from mezzanine.conf import settings @@ -28,7 +27,6 @@ class Meta: abstract = True -@python_2_unicode_compatible class Page(BasePage, ContentTyped): """ A page in the page tree. This is the base class that custom content types diff --git a/mezzanine/pages/templates/admin/pages/page/change_list.html b/mezzanine/pages/templates/admin/pages/page/change_list.html index 46cfd36047..7c8dbc37cd 100644 --- a/mezzanine/pages/templates/admin/pages/page/change_list.html +++ b/mezzanine/pages/templates/admin/pages/page/change_list.html @@ -1,5 +1,5 @@ {% extends "admin/change_list.html" %} -{% load pages_tags staticfiles %} +{% load pages_tags static %} {% block extrahead %} {{ block.super }} diff --git a/mezzanine/pages/templates/pages/menus/admin.html b/mezzanine/pages/templates/pages/menus/admin.html index 540c563469..84c3b5ef5c 100644 --- a/mezzanine/pages/templates/pages/menus/admin.html +++ b/mezzanine/pages/templates/pages/menus/admin.html @@ -1,4 +1,4 @@ -{% load pages_tags i18n staticfiles %} +{% load pages_tags i18n static %}
    {% for page in page_branch %} diff --git a/mezzanine/utils/cache.py b/mezzanine/utils/cache.py index cb23939847..5c18757048 100644 --- a/mezzanine/utils/cache.py +++ b/mezzanine/utils/cache.py @@ -1,8 +1,8 @@ +from functools import lru_cache from hashlib import md5 from time import time from django.core.cache import cache -from django.utils.lru_cache import lru_cache from django.utils.cache import _i18n_cache_key_suffix from mezzanine.conf import settings diff --git a/mezzanine/utils/static.py b/mezzanine/utils/static.py index 0d6532f03e..fa98b58410 100644 --- a/mezzanine/utils/static.py +++ b/mezzanine/utils/static.py @@ -1,7 +1,7 @@ """ Utils for working with static files. """ -from django.contrib.admin.templatetags.admin_static import static +from django.templatetags.static import static from django.conf import settings from django.utils.functional import lazy