Skip to content
Snippets Groups Projects
Commit c6c9a4d1 authored by David Douard's avatar David Douard
Browse files

web: Ensure the swhid url converter is registered soon

The correct behavior was depending on the order in which swh.web django
apps are registered. This should allow to have less entries in the
SWH_BASE_DJANGO_APPS so we can have an instance only serving /api for
example (which is currently not possible).
parent e0afc520
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,9 @@
from typing import List, Optional
# call this early to ensure all the 'swhid' url path converted is registered
# so any url registration will work as intended
import swh.web.utils.url_path_converters # noqa: F401
from swh.web.utils.urlsindex import UrlsIndex
browse_urls = UrlsIndex()
......
......@@ -17,7 +17,6 @@ import swh.web.browse.views.release # noqa
import swh.web.browse.views.revision # noqa
import swh.web.browse.views.snapshot # noqa
from swh.web.utils import origin_visit_types, reverse
from swh.web.utils.url_path_converters import register_url_path_converters
def _browse_help_view(request: HttpRequest) -> HttpResponse:
......@@ -45,8 +44,6 @@ def _browse_swhid_iframe_legacy(request: HttpRequest, swhid: str) -> HttpRespons
return redirect(reverse("browse-swhid-iframe", url_args={"swhid": swhid}))
register_url_path_converters()
urlpatterns = [
url("browse/", _browse_search_view),
url("browse/help/", _browse_help_view, name="browse-help"),
......
......@@ -42,3 +42,6 @@ def register_url_path_converters() -> None:
"""
if "swhid" not in REGISTERED_CONVERTERS:
register_converter(SWHIDConverter, "swhid")
register_url_path_converters()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment