Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/views/snapshot.py
# Copyright (C) 2018-2019 The Software Heritage developers | # Copyright (C) 2018-2019 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.browse.browseurls import browse_route | from swh.web.browse.browseurls import browse_route | ||||
from swh.web.browse.snapshot_context import ( | from swh.web.browse.snapshot_context import ( | ||||
browse_snapshot_branches, | browse_snapshot_branches, | ||||
browse_snapshot_directory, | |||||
browse_snapshot_log, | browse_snapshot_log, | ||||
browse_snapshot_releases, | browse_snapshot_releases, | ||||
get_snapshot_context, | get_snapshot_context, | ||||
) | ) | ||||
from swh.web.common.exc import BadInputExc | from swh.web.common.exc import BadInputExc | ||||
from swh.web.common.utils import redirect_to_new_route, reverse | from swh.web.common.utils import redirect_to_new_route, reverse | ||||
Show All 27 Lines | |||||
@browse_route( | @browse_route( | ||||
r"snapshot/(?P<snapshot_id>[0-9a-f]+)/directory/", | r"snapshot/(?P<snapshot_id>[0-9a-f]+)/directory/", | ||||
view_name="browse-snapshot-directory", | view_name="browse-snapshot-directory", | ||||
checksum_args=["snapshot_id"], | checksum_args=["snapshot_id"], | ||||
) | ) | ||||
def snapshot_directory_browse(request, snapshot_id): | def snapshot_directory_browse(request, snapshot_id): | ||||
"""Django view for browsing the content of a directory collected | """ | ||||
This route is deprecated; use http:get:`/browse/directory` instead | |||||
Django view for browsing the content of a directory collected | |||||
in a snapshot. | in a snapshot. | ||||
The URL that points to it is :http:get:`/browse/snapshot/(snapshot_id)/directory/` | The URL that points to it is :http:get:`/browse/snapshot/(snapshot_id)/directory/` | ||||
""" | """ | ||||
return browse_snapshot_directory( | return redirect_to_new_route(request, "browse-directory") | ||||
request, | |||||
snapshot_id=snapshot_id, | |||||
path=request.GET.get("path"), | |||||
origin_url=request.GET.get("origin_url"), | |||||
) | |||||
@browse_route( | @browse_route( | ||||
r"snapshot/(?P<snapshot_id>[0-9a-f]+)/directory/(?P<path>.+)/", | r"snapshot/(?P<snapshot_id>[0-9a-f]+)/directory/(?P<path>.+)/", | ||||
view_name="browse-snapshot-directory-legacy", | view_name="browse-snapshot-directory-legacy", | ||||
checksum_args=["snapshot_id"], | checksum_args=["snapshot_id"], | ||||
) | ) | ||||
def snapshot_directory_browse_legacy(request, snapshot_id, path=None): | def snapshot_directory_browse_legacy(request, snapshot_id, path=None): | ||||
"""Django view for browsing the content of a directory collected | """ | ||||
This route is deprecated; use http:get:`/browse/directory` instead | |||||
Django view for browsing the content of a directory collected | |||||
in a snapshot. | in a snapshot. | ||||
The URL that points to it is | The URL that points to it is | ||||
:http:get:`/browse/snapshot/(snapshot_id)/directory/(path)/` | :http:get:`/browse/snapshot/(snapshot_id)/directory/(path)/` | ||||
""" | """ | ||||
origin_url = request.GET.get("origin_url", None) | return redirect_to_new_route(request, "browse-directory") | ||||
if not origin_url: | |||||
origin_url = request.GET.get("origin", None) | |||||
return browse_snapshot_directory( | |||||
request, snapshot_id=snapshot_id, path=path, origin_url=origin_url | |||||
) | |||||
@browse_route( | @browse_route( | ||||
r"snapshot/(?P<snapshot_id>[0-9a-f]+)/content/", | r"snapshot/(?P<snapshot_id>[0-9a-f]+)/content/", | ||||
view_name="browse-snapshot-content", | view_name="browse-snapshot-content", | ||||
checksum_args=["snapshot_id"], | checksum_args=["snapshot_id"], | ||||
) | ) | ||||
def snapshot_content_browse(request, snapshot_id): | def snapshot_content_browse(request, snapshot_id): | ||||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |