diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-10-15 19:03:22 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-10-15 19:32:59 +0200 |
commit | 31ae6562099cca5e692fdcdccf0852433d295a3a (patch) | |
tree | 365de723a1b9430e1d6f44618c52f2dd4a1abe48 /ishtar_common/utils.py | |
parent | f5077bcd3cea76f48a2d635385e4b85a16bf6000 (diff) | |
download | Ishtar-31ae6562099cca5e692fdcdccf0852433d295a3a.tar.bz2 Ishtar-31ae6562099cca5e692fdcdccf0852433d295a3a.zip |
♻️ django 3.2 deprecation: url -> re_path ; ugettext_lazy -> gettext_lazy
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 65c0128ab..bd20e4919 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 @@ -84,20 +83,20 @@ from .jinja_filters import capfirst_filter, capitalize_filter, \ 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__) @@ -1300,7 +1299,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: @@ -2301,7 +2300,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<pk>.+))?/(?P<type>.+)?$".format(model.SLUG), check_permissions( [f"{app_label}.view_{model_name}", @@ -2310,7 +2309,7 @@ def get_urls_for_model( ), name="show-" + model.SLUG, ), - url( + re_path( r"^display-{}/(?P<pk>.+)/$".format(model.SLUG), check_permissions( [f"{app_label}.view_{model_name}", @@ -2322,7 +2321,7 @@ def get_urls_for_model( ] if own: urls += [ - url( + re_path( r"get-{}/own/(?P<type>.+)?$".format(model.SLUG), check_permissions( [f"{app_label}.view_{model_name}", @@ -2335,7 +2334,7 @@ def get_urls_for_model( ] urls += [ - url( + re_path( r"get-{}/(?P<type>.+)?$".format(model.SLUG), check_permissions( [f"{app_label}.view_{model_name}", @@ -2348,7 +2347,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}", |