Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/identifiers.py
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2020 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.shortcuts import redirect | from django.shortcuts import redirect | ||||
from swh.web.common.identifiers import resolve_swh_persistent_id | from swh.web.common.identifiers import resolve_swhid | ||||
from swh.web.common.exc import handle_view_exception | from swh.web.common.exc import handle_view_exception | ||||
def swh_id_browse(request, swh_id): | def swhid_browse(request, swhid): | ||||
""" | """ | ||||
Django view enabling to browse the archive using | Django view enabling to browse the archive using :ref:`<persistent-identifiers>`. | ||||
:ref:`SWHIDs <persistent-identifiers>`. | |||||
The url that points to it is :http:get:`/(swh_id)/`. | The url that points to it is :http:get:`/(swhid)/`. | ||||
""" | """ | ||||
try: | try: | ||||
swh_id_resolved = resolve_swh_persistent_id(swh_id, query_params=request.GET) | swhid_resolved = resolve_swhid(swhid, query_params=request.GET) | ||||
except Exception as exc: | except Exception as exc: | ||||
return handle_view_exception(request, exc) | return handle_view_exception(request, exc) | ||||
return redirect(swh_id_resolved["browse_url"]) | return redirect(swhid_resolved["browse_url"]) |