diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-06-13 18:08:00 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-06-13 18:08:00 +0200 |
commit | 7e6016b2bb9732b6b2432ec9329213a1d0c9c9a5 (patch) | |
tree | e0578d822d2a267b3f48c1e032fce9e77809e4ae /ishtar_common/utils.py | |
parent | 17426c62ae8bd08d9c66ac0f97dbad1f26d8d154 (diff) | |
download | Ishtar-7e6016b2bb9732b6b2432ec9329213a1d0c9c9a5.tar.bz2 Ishtar-7e6016b2bb9732b6b2432ec9329213a1d0c9c9a5.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 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<pk>.+))?/(?P<type>.+)?$".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<pk>.+)/$".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<type>.+)?$".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<type>.+)?$".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}", |