Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/snapshot_context.py
Show First 20 Lines • Show All 1,208 Lines • ▼ Show 20 Lines | return render( | ||||
"vault_cooking": None, | "vault_cooking": None, | ||||
"show_actions": True, | "show_actions": True, | ||||
"swhids_info": swhids_info, | "swhids_info": swhids_info, | ||||
}, | }, | ||||
) | ) | ||||
def browse_snapshot_branches( | def browse_snapshot_branches( | ||||
request, snapshot_id=None, origin_url=None, timestamp=None | request, snapshot_id=None, origin_url=None, timestamp=None, branch_name_include=None | ||||
anlambert: You should rename `branchname_include` parameter to `branch_name_include` for consistency. | |||||
): | ): | ||||
""" | """ | ||||
Django view implementation for browsing a list of branches in a snapshot | Django view implementation for browsing a list of branches in a snapshot | ||||
context. | context. | ||||
""" | """ | ||||
_check_origin_url(snapshot_id, origin_url) | _check_origin_url(snapshot_id, origin_url) | ||||
snapshot_context = get_snapshot_context( | snapshot_context = get_snapshot_context( | ||||
Show All 16 Lines | ): | ||||
else: | else: | ||||
browse_view_name = "browse-snapshot-directory" | browse_view_name = "browse-snapshot-directory" | ||||
snapshot = archive.lookup_snapshot( | snapshot = archive.lookup_snapshot( | ||||
snapshot_context["snapshot_id"], | snapshot_context["snapshot_id"], | ||||
branches_from, | branches_from, | ||||
PER_PAGE + 1, | PER_PAGE + 1, | ||||
target_types=["revision", "alias"], | target_types=["revision", "alias"], | ||||
branch_name_include_substring=branch_name_include, | |||||
) | ) | ||||
displayed_branches = [] | |||||
if snapshot: | |||||
displayed_branches, _, _ = process_snapshot_branches(snapshot) | displayed_branches, _, _ = process_snapshot_branches(snapshot) | ||||
for branch in displayed_branches: | for branch in displayed_branches: | ||||
rev_query_params = {} | rev_query_params = {} | ||||
if origin_info: | if origin_info: | ||||
rev_query_params["origin_url"] = origin_info["url"] | rev_query_params["origin_url"] = origin_info["url"] | ||||
revision_url = reverse( | revision_url = reverse( | ||||
"browse-revision", | "browse-revision", | ||||
Show All 24 Lines | if branches_bc: | ||||
prev_branches_url = reverse( | prev_branches_url = reverse( | ||||
browse_view_name, url_args=url_args, query_params=query_params_prev | browse_view_name, url_args=url_args, query_params=query_params_prev | ||||
) | ) | ||||
elif branches_from: | elif branches_from: | ||||
prev_branches_url = reverse( | prev_branches_url = reverse( | ||||
browse_view_name, url_args=url_args, query_params=query_params | browse_view_name, url_args=url_args, query_params=query_params | ||||
) | ) | ||||
if snapshot["next_branch"] is not None: | if snapshot and snapshot["next_branch"] is not None: | ||||
query_params_next = dict(query_params) | query_params_next = dict(query_params) | ||||
next_branch = displayed_branches[-1]["name"] | next_branch = displayed_branches[-1]["name"] | ||||
del displayed_branches[-1] | del displayed_branches[-1] | ||||
branches_bc.append(next_branch) | branches_bc.append(next_branch) | ||||
query_params_next["branches_breadcrumbs"] = ",".join(branches_bc) | query_params_next["branches_breadcrumbs"] = ",".join(branches_bc) | ||||
next_branches_url = reverse( | next_branches_url = reverse( | ||||
browse_view_name, url_args=url_args, query_params=query_params_next | browse_view_name, url_args=url_args, query_params=query_params_next | ||||
) | ) | ||||
Show All 11 Lines | return render( | ||||
"heading": heading, | "heading": heading, | ||||
"swh_object_name": "Branches", | "swh_object_name": "Branches", | ||||
"swh_object_metadata": {}, | "swh_object_metadata": {}, | ||||
"top_right_link": None, | "top_right_link": None, | ||||
"displayed_branches": displayed_branches, | "displayed_branches": displayed_branches, | ||||
"prev_branches_url": prev_branches_url, | "prev_branches_url": prev_branches_url, | ||||
"next_branches_url": next_branches_url, | "next_branches_url": next_branches_url, | ||||
"snapshot_context": snapshot_context, | "snapshot_context": snapshot_context, | ||||
"search_string": branch_name_include or "", | |||||
}, | }, | ||||
) | ) | ||||
def browse_snapshot_releases( | def browse_snapshot_releases( | ||||
request, snapshot_id=None, origin_url=None, timestamp=None | request, snapshot_id=None, origin_url=None, timestamp=None | ||||
): | ): | ||||
""" | """ | ||||
Show All 18 Lines | ): | ||||
query_params = snapshot_context["query_params"] | query_params = snapshot_context["query_params"] | ||||
snapshot = archive.lookup_snapshot( | snapshot = archive.lookup_snapshot( | ||||
snapshot_context["snapshot_id"], | snapshot_context["snapshot_id"], | ||||
rel_from, | rel_from, | ||||
PER_PAGE + 1, | PER_PAGE + 1, | ||||
target_types=["release", "alias"], | target_types=["release", "alias"], | ||||
) | ) | ||||
_, displayed_releases, _ = process_snapshot_branches(snapshot) | _, displayed_releases, _ = process_snapshot_branches(snapshot) | ||||
for release in displayed_releases: | for release in displayed_releases: | ||||
query_params_tgt = {"snapshot": snapshot_id} | query_params_tgt = {"snapshot": snapshot_id} | ||||
if origin_info: | if origin_info: | ||||
query_params_tgt["origin_url"] = origin_info["url"] | query_params_tgt["origin_url"] = origin_info["url"] | ||||
release_url = reverse( | release_url = reverse( | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |
You should rename branchname_include parameter to branch_name_include for consistency.