diff --git a/swh/web/admin/__init__.py b/swh/web/admin/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/swh/web/admin/adminurls.py b/swh/web/admin/adminurls.py deleted file mode 100644 index 3186114e..00000000 --- a/swh/web/admin/adminurls.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 2018-2019 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 swh.web.common.urlsindex import UrlsIndex - - -class AdminUrls(UrlsIndex): - """ - Class to manage swh-web admin urls. - """ - - scope = "admin" - - -def admin_route(*url_patterns, view_name=None): - """ - Decorator to ease the registration of a swh-web admin endpoint - - Args: - url_patterns: list of url patterns used by Django to identify the - admin routes - view_name: the name of the Django view associated to the routes used - to reverse the url - """ - url_patterns = ["^" + url_pattern + "$" for url_pattern in url_patterns] - - def decorator(f): - # register the route and its view in the browse endpoints index - for url_pattern in url_patterns: - AdminUrls.add_url_pattern(url_pattern, f, view_name) - return f - - return decorator diff --git a/swh/web/admin/urls.py b/swh/web/admin/urls.py deleted file mode 100644 index 467aeaba..00000000 --- a/swh/web/admin/urls.py +++ /dev/null @@ -1,21 +0,0 @@ -# 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.shortcuts import redirect -from django.urls import re_path as url - -from swh.web.admin.adminurls import AdminUrls - - -def _admin_default_view(request): - return redirect("admin-origin-save-requests") - - -urlpatterns = [ - url(r"^$", _admin_default_view, name="admin"), -] - -urlpatterns += AdminUrls.get_url_patterns() diff --git a/swh/web/tests/admin/__init__.py b/swh/web/tests/admin/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/swh/web/urls.py b/swh/web/urls.py index 9f724413..42e12cd7 100644 --- a/swh/web/urls.py +++ b/swh/web/urls.py @@ -1,83 +1,82 @@ # 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 importlib.util import find_spec from django_js_reverse.views import urls_js from django.conf import settings from django.conf.urls import handler400, handler403, handler404, handler500, include 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 from swh.web.common.exc import ( swh_handle400, swh_handle403, swh_handle404, swh_handle500, ) from swh.web.common.utils import origin_visit_types from swh.web.config import get_config swh_web_config = get_config() favicon_view = RedirectView.as_view( url="/static/img/icons/swh-logo-32x32.png", permanent=True ) def _default_view(request): return render(request, "homepage.html", {"visit_types": origin_visit_types()}) urlpatterns = [ - url(r"^admin/", include("swh.web.admin.urls")), url(r"^favicon\.ico/$", favicon_view), url(r"^$", _default_view, name="swh-web-homepage"), url(r"^jsreverse/$", urls_js, name="js_reverse"), # keep legacy SWHID resolving URL with trailing slash for backward compatibility url( r"^(?P(swh|SWH):[0-9]+:[A-Za-z]+:[0-9A-Fa-f]+.*)/$", swhid_browse, name="browse-swhid-legacy", ), url( r"^(?P(swh|SWH):[0-9]+:[A-Za-z]+:[0-9A-Fa-f]+.*)$", swhid_browse, name="browse-swhid", ), url(r"^", include("swh.web.misc.urls")), ] # Register URLs for each SWH Django application for app in settings.SWH_DJANGO_APPS: app_urls = app + ".urls" try: app_urls_spec = find_spec(app_urls) if app_urls_spec is not None: urlpatterns.append(url(r"^", include(app_urls))) except ModuleNotFoundError: assert False, f"Django application {app} not found !" # allow to serve assets through django staticfiles # even if settings.DEBUG is False def insecure_serve(request, path, **kwargs): return serve(request, path, insecure=True, **kwargs) # enable to serve compressed assets through django development server if swh_web_config["serve_assets"]: static_pattern = r"^%s(?P.*)/$" % settings.STATIC_URL[1:] urlpatterns.append(url(static_pattern, insecure_serve)) handler400 = swh_handle400 # noqa handler403 = swh_handle403 # noqa handler404 = swh_handle404 # noqa handler500 = swh_handle500 # noqa