From 7e6016b2bb9732b6b2432ec9329213a1d0c9c9a5 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 13 Jun 2025 18:08:00 +0200 Subject: ♻️ django 3.2 deprecation: url -> re_path ; ugettext_lazy -> gettext_lazy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/utils.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 4e558ebd0..b4437b367 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -54,7 +54,6 @@ import zipfile from django import forms from django.apps import apps from django.conf import settings -from django.conf.urls import url from django.contrib.auth.models import Permission, User, Group from django.contrib.auth.hashers import Argon2PasswordHasher as BaseArgon2PasswordHasher from django.contrib.contenttypes.models import ContentType @@ -70,7 +69,7 @@ from django.db import models from django.db.models import Q from django.db.models.functions import Length from django.http import HttpResponseRedirect -from django.urls import reverse, NoReverseMatch +from django.urls import re_path, reverse, NoReverseMatch from django.utils.crypto import get_random_string from django.utils.datastructures import MultiValueDict as BaseMultiValueDict from django.utils.formats import date_format @@ -80,20 +79,20 @@ from django.template.defaultfilters import slugify if settings.USE_TRANSLATION_OVERLOAD: from overload_translation.utils import ( - ugettext_lazy, - ugettext, + gettext_lazy, + gettext, pgettext_lazy, pgettext, ) else: from django.utils.translation import ( - ugettext_lazy, - ugettext, + gettext_lazy, + gettext, pgettext_lazy, pgettext, ) -_ = ugettext_lazy +_ = gettext_lazy logger = logging.getLogger(__name__) @@ -1294,7 +1293,7 @@ def _external_id_changed(sender, **kwargs): def shortify(lbl, number=20): - SHORTIFY_STR = ugettext(" (...)") + SHORTIFY_STR = gettext(" (...)") if not lbl: lbl = "" if len(lbl) <= number: @@ -2295,7 +2294,7 @@ def get_urls_for_model( app_label = model._meta.app_label model_name = model._meta.model_name urls = [ - url( + re_path( r"show-{}(?:/(?P.+))?/(?P.+)?$".format(model.SLUG), check_permissions( [f"{app_label}.view_{model_name}", @@ -2304,7 +2303,7 @@ def get_urls_for_model( ), name="show-" + model.SLUG, ), - url( + re_path( r"^display-{}/(?P.+)/$".format(model.SLUG), check_permissions( [f"{app_label}.view_{model_name}", @@ -2316,7 +2315,7 @@ def get_urls_for_model( ] if own: urls += [ - url( + re_path( r"get-{}/own/(?P.+)?$".format(model.SLUG), check_permissions( [f"{app_label}.view_{model_name}", @@ -2329,7 +2328,7 @@ def get_urls_for_model( ] urls += [ - url( + re_path( r"get-{}/(?P.+)?$".format(model.SLUG), check_permissions( [f"{app_label}.view_{model_name}", @@ -2342,7 +2341,7 @@ def get_urls_for_model( if autocomplete: urls += [ - url( + re_path( r"autocomplete-{}/$".format(model.SLUG), check_permissions( [f"{app_label}.view_{model_name}", -- cgit v1.2.3