Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/views/snapshot.py
| Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | return browse_snapshot_log( | ||||
| snapshot_id=snapshot_id, | snapshot_id=snapshot_id, | ||||
| origin_url=request.GET.get("origin_url"), | origin_url=request.GET.get("origin_url"), | ||||
| timestamp=request.GET.get("timestamp"), | timestamp=request.GET.get("timestamp"), | ||||
| ) | ) | ||||
| @browse_route( | @browse_route( | ||||
| r"snapshot/(?P<snapshot_id>[0-9a-f]+)/branches/", | r"snapshot/(?P<snapshot_id>[0-9a-f]+)/branches/", | ||||
| r"snapshot/branches/", | |||||
| view_name="browse-snapshot-branches", | view_name="browse-snapshot-branches", | ||||
| checksum_args=["snapshot_id"], | checksum_args=["snapshot_id"], | ||||
| ) | ) | ||||
| def snapshot_branches_browse(request, snapshot_id): | def snapshot_branches_browse(request, snapshot_id=None): | ||||
| """Django view that produces an HTML display of the list of releases | """Django view that produces an HTML display of the list of branches | ||||
| collected in a snapshot. | collected in a snapshot. | ||||
| The url that points to it is | The URLs that point to it are | ||||
| :http:get:`/browse/snapshot/(snapshot_id)/branches/` | :http:get:`/browse/snapshot/(snapshot_id)/branches/` and | ||||
| :http:get:`/browse/snapshot/branches/` | |||||
| """ | """ | ||||
| return browse_snapshot_branches(request, snapshot_id=snapshot_id) | if snapshot_id is None: | ||||
| # This case happens when redirected from /origin/branches | |||||
| snapshot_id = get_snapshot_from_request(request) | |||||
| # Redirect to the same route with the newest snapshot_id | |||||
| # for the given origin | |||||
| return redirect( | |||||
| reverse( | |||||
| "browse-snapshot-branches", | |||||
| url_args={"snapshot_id": snapshot_id}, | |||||
| query_params=request.GET, | |||||
| ), | |||||
| ) | |||||
| return browse_snapshot_branches( | |||||
| request, | |||||
| snapshot_id=snapshot_id, | |||||
| origin_url=request.GET.get("origin_url"), | |||||
| timestamp=request.GET.get("timestamp"), | |||||
| branch_name_include=request.GET.get("name_include"), | |||||
| ) | |||||
| @browse_route( | @browse_route( | ||||
| r"snapshot/(?P<snapshot_id>[0-9a-f]+)/releases/", | r"snapshot/(?P<snapshot_id>[0-9a-f]+)/releases/", | ||||
| view_name="browse-snapshot-releases", | view_name="browse-snapshot-releases", | ||||
| checksum_args=["snapshot_id"], | checksum_args=["snapshot_id"], | ||||
| ) | ) | ||||
| def snapshot_releases_browse(request, snapshot_id): | def snapshot_releases_browse(request, snapshot_id): | ||||
| """Django view that produces an HTML display of the list of releases | """Django view that produces an HTML display of the list of releases | ||||
| collected in a snapshot. | collected in a snapshot. | ||||
| The url that points to it is | The url that points to it is | ||||
| :http:get:`/browse/snapshot/(snapshot_id)/releases/` | :http:get:`/browse/snapshot/(snapshot_id)/releases/` | ||||
| """ | """ | ||||
| return browse_snapshot_releases(request, snapshot_id=snapshot_id) | return browse_snapshot_releases(request, snapshot_id=snapshot_id) | ||||