Page MenuHomeSoftware Heritage

D8115.id29318.diff
No OneTemporary

D8115.id29318.diff

diff --git a/swh/web/add_forge_now/views.py b/swh/web/add_forge_now/views.py
--- a/swh/web/add_forge_now/views.py
+++ b/swh/web/add_forge_now/views.py
@@ -6,13 +6,13 @@
from typing import Any, Dict, List
from django.conf import settings
-from django.conf.urls import url
from django.contrib.auth.decorators import user_passes_test
from django.core.paginator import Paginator
from django.db.models import Q
from django.http.request import HttpRequest
from django.http.response import HttpResponse, JsonResponse
from django.shortcuts import render
+from django.urls import re_path as url
from swh.web.add_forge_now.models import Request as AddForgeRequest
from swh.web.add_forge_now.models import RequestHistory
diff --git a/swh/web/admin/urls.py b/swh/web/admin/urls.py
--- a/swh/web/admin/urls.py
+++ b/swh/web/admin/urls.py
@@ -3,9 +3,9 @@
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
-from django.conf.urls import url
from django.contrib.auth.views import LoginView
from django.shortcuts import redirect
+from django.urls import re_path as url
from swh.web.admin.adminurls import AdminUrls
import swh.web.admin.deposit # noqa
diff --git a/swh/web/auth/mailmap.py b/swh/web/auth/mailmap.py
--- a/swh/web/auth/mailmap.py
+++ b/swh/web/auth/mailmap.py
@@ -6,7 +6,6 @@
import json
from typing import Any, Dict
-from django.conf.urls import url
from django.core.paginator import Paginator
from django.db import IntegrityError
from django.db.models import Q
@@ -17,6 +16,7 @@
HttpResponseNotFound,
JsonResponse,
)
+from django.urls import re_path as url
from rest_framework import serializers
from rest_framework.decorators import api_view
from rest_framework.request import Request
diff --git a/swh/web/auth/views.py b/swh/web/auth/views.py
--- a/swh/web/auth/views.py
+++ b/swh/web/auth/views.py
@@ -8,7 +8,6 @@
from cryptography.fernet import InvalidToken
-from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator
from django.http import HttpRequest
@@ -20,6 +19,7 @@
JsonResponse,
)
from django.shortcuts import render
+from django.urls import re_path as url
from django.views.decorators.http import require_http_methods
from swh.auth.django.models import OIDCUser
diff --git a/swh/web/browse/urls.py b/swh/web/browse/urls.py
--- a/swh/web/browse/urls.py
+++ b/swh/web/browse/urls.py
@@ -3,9 +3,9 @@
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
-from django.conf.urls import url
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect, render
+from django.urls import re_path as url
from swh.web.browse.browseurls import BrowseUrls
from swh.web.browse.identifiers import swhid_browse
diff --git a/swh/web/common/urlsindex.py b/swh/web/common/urlsindex.py
--- a/swh/web/common/urlsindex.py
+++ b/swh/web/common/urlsindex.py
@@ -1,13 +1,13 @@
-# Copyright (C) 2017-2019 The Software Heritage developers
+# Copyright (C) 2017-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
from typing import Dict, List
-from django.conf.urls import url
from django.shortcuts import redirect
-import django.urls
+from django.urls import URLPattern
+from django.urls import re_path as url
class UrlsIndex(object):
@@ -19,7 +19,7 @@
all declared patterns will be grouped under the default one.
"""
- _urlpatterns = {} # type: Dict[str, List[django.urls.URLPattern]]
+ _urlpatterns: Dict[str, List[URLPattern]] = {}
scope = "default"
@classmethod
diff --git a/swh/web/inbound_email/__init__.py b/swh/web/inbound_email/__init__.py
--- a/swh/web/inbound_email/__init__.py
+++ b/swh/web/inbound_email/__init__.py
@@ -0,0 +1,6 @@
+# Copyright (C) 2022 The Software Heritage developers
+# See the AUTHORS file at the top-level directory of this distribution
+# License: GNU Affero General Public License version 3, or any later version
+# See top-level LICENSE file for more information
+
+default_app_config = "swh.web.inbound_email.apps.InboundEmailConfig"
diff --git a/swh/web/inbound_email/apps.py b/swh/web/inbound_email/apps.py
--- a/swh/web/inbound_email/apps.py
+++ b/swh/web/inbound_email/apps.py
@@ -8,4 +8,4 @@
class InboundEmailConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
- name = "inbound_email"
+ name = "swh.web.inbound_email"
diff --git a/swh/web/inbound_email/signals.py b/swh/web/inbound_email/signals.py
--- a/swh/web/inbound_email/signals.py
+++ b/swh/web/inbound_email/signals.py
@@ -7,7 +7,7 @@
import django.dispatch
-email_received = django.dispatch.Signal(providing_args=["message"])
+email_received = django.dispatch.Signal()
"""This signal is sent by the `process_inbound_email` management command.
Arguments:
diff --git a/swh/web/misc/badges.py b/swh/web/misc/badges.py
--- a/swh/web/misc/badges.py
+++ b/swh/web/misc/badges.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2021 The Software Heritage developers
+# Copyright (C) 2019-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
@@ -8,9 +8,9 @@
from pybadges import badge
-from django.conf.urls import url
from django.contrib.staticfiles import finders
from django.http import HttpRequest, HttpResponse
+from django.urls import re_path as url
from swh.model.exceptions import ValidationError
from swh.model.hashutil import hash_to_bytes, hash_to_hex
diff --git a/swh/web/misc/coverage.py b/swh/web/misc/coverage.py
--- a/swh/web/misc/coverage.py
+++ b/swh/web/misc/coverage.py
@@ -7,10 +7,10 @@
from typing import Any, Dict, List, Tuple
from urllib.parse import urlparse
-from django.conf.urls import url
from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.shortcuts import render
+from django.urls import re_path as url
from django.views.decorators.cache import never_cache
from django.views.decorators.clickjacking import xframe_options_exempt
diff --git a/swh/web/misc/fundraising.py b/swh/web/misc/fundraising.py
--- a/swh/web/misc/fundraising.py
+++ b/swh/web/misc/fundraising.py
@@ -1,12 +1,12 @@
-# Copyright (C) 2021 The Software Heritage developers
+# Copyright (C) 2021-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
import requests
-from django.conf.urls import url
from django.shortcuts import render
+from django.urls import re_path as url
from django.views.decorators.clickjacking import xframe_options_exempt
from swh.web.config import get_config
diff --git a/swh/web/misc/iframe.py b/swh/web/misc/iframe.py
--- a/swh/web/misc/iframe.py
+++ b/swh/web/misc/iframe.py
@@ -1,12 +1,12 @@
-# Copyright (C) 2021 The Software Heritage developers
+# Copyright (C) 2021-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
from typing import Any, Dict, List, Optional, Tuple
-from django.conf.urls import url
from django.shortcuts import render
+from django.urls import re_path as url
from django.views.decorators.clickjacking import xframe_options_exempt
from swh.model.hashutil import hash_to_bytes
diff --git a/swh/web/misc/origin_save.py b/swh/web/misc/origin_save.py
--- a/swh/web/misc/origin_save.py
+++ b/swh/web/misc/origin_save.py
@@ -1,13 +1,13 @@
-# Copyright (C) 2018-2021 The Software Heritage developers
+# Copyright (C) 2018-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
-from django.conf.urls import url
from django.core.paginator import Paginator
from django.db.models import Q
from django.http import JsonResponse
from django.shortcuts import render
+from django.urls import re_path as url
from swh.web.auth.utils import SWH_AMBASSADOR_PERMISSION, privileged_user
from swh.web.common.models import SaveOriginRequest
diff --git a/swh/web/misc/urls.py b/swh/web/misc/urls.py
--- a/swh/web/misc/urls.py
+++ b/swh/web/misc/urls.py
@@ -7,10 +7,11 @@
import requests
-from django.conf.urls import include, url
+from django.conf.urls import include
from django.contrib.staticfiles import finders
from django.http import JsonResponse
from django.shortcuts import render
+from django.urls import re_path as url
from django.views.decorators.clickjacking import xframe_options_exempt
from swh.web.common import archive
diff --git a/swh/web/settings/common.py b/swh/web/settings/common.py
--- a/swh/web/settings/common.py
+++ b/swh/web/settings/common.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2017-2021 The Software Heritage developers
+# Copyright (C) 2017-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
@@ -12,9 +12,17 @@
import sys
from typing import Any, Dict
+from django.utils import encoding
+
from swh.web.auth.utils import OIDC_SWH_WEB_CLIENT_ID
from swh.web.config import get_config
+# Fix django-js-reverse 0.9.1 compatibility with django 4.x
+# TODO: Remove that hack once a new django-js-reverse release
+# is available on PyPI
+if not hasattr(encoding, "force_text"):
+ setattr(encoding, "force_text", encoding.force_str)
+
swh_web_config = get_config()
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@@ -310,3 +318,5 @@
SWH_AUTH_REALM_NAME = swh_web_config["keycloak"]["realm_name"]
SWH_AUTH_CLIENT_ID = OIDC_SWH_WEB_CLIENT_ID
SWH_AUTH_SESSION_EXPIRED_REDIRECT_VIEW = "logout"
+
+DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
diff --git a/swh/web/tests/api/test_throttling.py b/swh/web/tests/api/test_throttling.py
--- a/swh/web/tests/api/test_throttling.py
+++ b/swh/web/tests/api/test_throttling.py
@@ -1,12 +1,12 @@
-# Copyright (C) 2017-2021 The Software Heritage developers
+# Copyright (C) 2017-2022 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
import pytest
-from django.conf.urls import url
from django.test.utils import override_settings
+from django.urls import re_path as url
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework.views import APIView
diff --git a/swh/web/tests/common/test_utils.py b/swh/web/tests/common/test_utils.py
--- a/swh/web/tests/common/test_utils.py
+++ b/swh/web/tests/common/test_utils.py
@@ -2,6 +2,7 @@
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
+
from base64 import b64encode
import datetime
import math
@@ -10,8 +11,8 @@
import pytest
-from django.conf.urls import url
from django.test.utils import override_settings
+from django.urls import re_path as url
from django.urls.exceptions import NoReverseMatch
from swh.web.common import utils
diff --git a/swh/web/urls.py b/swh/web/urls.py
--- a/swh/web/urls.py
+++ b/swh/web/urls.py
@@ -7,17 +7,11 @@
from django_js_reverse.views import urls_js
from django.conf import settings
-from django.conf.urls import (
- handler400,
- handler403,
- handler404,
- handler500,
- include,
- url,
-)
+from django.conf.urls import handler400, handler403, handler404, handler500, include
from django.contrib.auth.views import LogoutView
from django.contrib.staticfiles.views import serve
from django.shortcuts import render
+from django.urls import re_path as url
from django.views.generic.base import RedirectView
from swh.web.browse.identifiers import swhid_browse

File Metadata

Mime Type
text/plain
Expires
Jul 3 2025, 8:11 AM (10 w, 19 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3223698

Event Timeline