Changeset View
Changeset View
Standalone View
Standalone View
swh/web/vault/urls.py
# Copyright (C) 2017-2022 The Software Heritage developers | # Copyright (C) 2017-2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from django.http import HttpRequest, HttpResponse | from django.http import HttpRequest, HttpResponse | ||||
from django.shortcuts import redirect, render | from django.shortcuts import redirect, render | ||||
from django.urls import re_path as url | from django.urls import re_path as url | ||||
# register Web API endpoints | # register Web API endpoints | ||||
import swh.web.vault.api_views # noqa | from swh.web.vault.api_views import vault_api_urls | ||||
def vault_view(request: HttpRequest) -> HttpResponse: | def vault_view(request: HttpRequest) -> HttpResponse: | ||||
return render( | return render( | ||||
request, | request, | ||||
"vault-ui.html", | "vault-ui.html", | ||||
{"heading": "Download archive content from the Vault"}, | {"heading": "Download archive content from the Vault"}, | ||||
) | ) | ||||
def browse_vault_view(request: HttpRequest) -> HttpResponse: | def browse_vault_view(request: HttpRequest) -> HttpResponse: | ||||
return redirect("vault") | return redirect("vault") | ||||
urlpatterns = [ | urlpatterns = [ | ||||
url(r"^vault/$", vault_view, name="vault"), | url(r"^vault/$", vault_view, name="vault"), | ||||
# for backward compatibility | # for backward compatibility | ||||
url(r"^browse/vault/$", browse_vault_view, name="browse-vault"), | url(r"^browse/vault/$", browse_vault_view, name="browse-vault"), | ||||
*vault_api_urls.get_url_patterns(), | |||||
] | ] | ||||
vlorentz: looks better IMO, but it works fine either way | |||||
Done Inline Actionsmore Pythonic indeed, will update every urls.py files with such construct anlambert: more Pythonic indeed, will update every `urls.py` files with such construct |
looks better IMO, but it works fine either way