diff --git a/jasmin_services/forms.py b/jasmin_services/forms.py index add6fff..4b9b9e7 100644 --- a/jasmin_services/forms.py +++ b/jasmin_services/forms.py @@ -10,6 +10,7 @@ from datetime import date import django.contrib.auth +import django.utils.encoding from dateutil.relativedelta import relativedelta from django import forms from django.conf import settings @@ -17,7 +18,6 @@ from django.contrib.auth import get_user_model from django.core.exceptions import ValidationError from django.urls import reverse -from django.utils.encoding import force_text from django.utils.safestring import mark_safe from markdown_deux.templatetags.markdown_deux_tags import markdown_allowed @@ -373,7 +373,7 @@ def __init__(self, switch_field_name, model_map, attrs=None): def render(self, name, value, attrs=None, renderer=None): if attrs is None: attrs = {} - value = force_text(value) if value else "" + value = django.utils.encoding.force_str(value) if value else "" attrs["class"] = "vForeignKeyRawIdAdminField" attrs["style"] = "width: 20em !important;" # Translate the model_map into an href_map diff --git a/jasmin_services/views/service_list.py b/jasmin_services/views/service_list.py index 984ca26..6ff85eb 100644 --- a/jasmin_services/views/service_list.py +++ b/jasmin_services/views/service_list.py @@ -1,4 +1,5 @@ import logging +import urllib.parse from django import http from django.conf import settings @@ -6,7 +7,6 @@ from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.db.models import Exists, OuterRef, Q from django.shortcuts import render -from django.utils.http import urlquote from django.views.decorators.http import require_safe from ..models import Category, Grant, Request @@ -142,7 +142,7 @@ def service_list(request, category): for service in page ], "page": page, - "preserved_filters": "query={}".format(urlquote(request.GET["query"])) + "preserved_filters": "query={}".format(urllib.parse.quote(request.GET["query"])) if "query" in request.GET else "", }, diff --git a/jasmin_services/widgets.py b/jasmin_services/widgets.py index bee607f..67c81f9 100644 --- a/jasmin_services/widgets.py +++ b/jasmin_services/widgets.py @@ -5,6 +5,7 @@ import json import django.urls +import django.utils.encoding from django import forms from django.contrib import admin from django.contrib.contenttypes.models import ContentType @@ -12,7 +13,6 @@ from django.http import HttpResponse from django.urls import reverse from django.urls.exceptions import NoReverseMatch -from django.utils.encoding import force_text ##### @@ -36,7 +36,7 @@ def generic_object_text(request): except ObjectDoesNotExist: content = "Object does not exist." else: - content = force_text(obj) + content = django.utils.encoding.force_str(obj) return HttpResponse(content=content, content_type="text/plain") @@ -101,7 +101,7 @@ def build_attrs(self, *args, **kwargs): ctype_url_map = {} for ctype in ContentType.objects.all(): try: - ctype_url_map[force_text(ctype.pk)] = reverse( + ctype_url_map[django.utils.encoding.force_str(ctype.pk)] = reverse( "admin:{}_{}_changelist".format(ctype.app_label, ctype.model), current_app=self.admin_site.name, ) diff --git a/pyproject.toml b/pyproject.toml index 8ca986c..bc1766c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ python = "^3.9" # Dependencies of dependencies. Need to specify here so poetry knows where to get them from. jasmin-ldap = {git = "https://github.com/cedadev/jasmin-ldap.git", tag = "v1.0.0"} -jasmin-django-utils = {git = "https://github.com/cedadev/jasmin-django-utils.git", tag = "v1.0.7" }# Also required for API. +jasmin-django-utils = {git = "https://github.com/cedadev/jasmin-django-utils.git", tag = "v1.0.8" }# Also required for API. Django = ">=3.2,!=4.0,!=4.1,<4.3" django-bootstrap5 = "^23.1"