Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/views/release.py
Show All 27 Lines | def release_browse(request, sha1_git): | ||||
The url that points to it is :http:get:`/browse/release/(sha1_git)/`. | The url that points to it is :http:get:`/browse/release/(sha1_git)/`. | ||||
""" | """ | ||||
try: | try: | ||||
release = service.lookup_release(sha1_git) | release = service.lookup_release(sha1_git) | ||||
snapshot_context = None | snapshot_context = None | ||||
origin_info = None | origin_info = None | ||||
snapshot_id = request.GET.get('snapshot_id', None) | snapshot_id = request.GET.get('snapshot_id', None) | ||||
origin_type = request.GET.get('origin_type', None) | |||||
origin_url = request.GET.get('origin_url', None) | origin_url = request.GET.get('origin_url', None) | ||||
if not origin_url: | if not origin_url: | ||||
origin_url = request.GET.get('origin', None) | origin_url = request.GET.get('origin', None) | ||||
timestamp = request.GET.get('timestamp', None) | timestamp = request.GET.get('timestamp', None) | ||||
visit_id = request.GET.get('visit_id', None) | visit_id = request.GET.get('visit_id', None) | ||||
if origin_url: | if origin_url: | ||||
try: | try: | ||||
snapshot_context = \ | snapshot_context = get_snapshot_context( | ||||
get_snapshot_context(snapshot_id, origin_type, | snapshot_id, origin_url, timestamp, visit_id) | ||||
origin_url, timestamp, | |||||
visit_id) | |||||
except Exception: | except Exception: | ||||
raw_rel_url = reverse('browse-release', | raw_rel_url = reverse('browse-release', | ||||
url_args={'sha1_git': sha1_git}) | url_args={'sha1_git': sha1_git}) | ||||
error_message = \ | error_message = \ | ||||
('The Software Heritage archive has a release ' | ('The Software Heritage archive has a release ' | ||||
'with the hash you provided but the origin ' | 'with the hash you provided but the origin ' | ||||
'mentioned in your request appears broken: %s. ' | 'mentioned in your request appears broken: %s. ' | ||||
'Please check the URL and try again.\n\n' | 'Please check the URL and try again.\n\n' | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | def release_browse(request, sha1_git): | ||||
release['target_link'] = target_link | release['target_link'] = target_link | ||||
if snapshot_context: | if snapshot_context: | ||||
release_data['snapshot'] = snapshot_context['snapshot_id'] | release_data['snapshot'] = snapshot_context['snapshot_id'] | ||||
if origin_info: | if origin_info: | ||||
release_data['context-independent release'] = \ | release_data['context-independent release'] = \ | ||||
gen_release_link(release['id']) | gen_release_link(release['id']) | ||||
release_data['origin type'] = origin_info['type'] | |||||
release_data['origin url'] = gen_link(origin_info['url'], | release_data['origin url'] = gen_link(origin_info['url'], | ||||
origin_info['url']) | origin_info['url']) | ||||
browse_snapshot_link = \ | browse_snapshot_link = \ | ||||
gen_snapshot_link(snapshot_context['snapshot_id']) | gen_snapshot_link(snapshot_context['snapshot_id']) | ||||
release_data['context-independent snapshot'] = browse_snapshot_link | release_data['context-independent snapshot'] = browse_snapshot_link | ||||
swh_objects = [{'type': 'release', | swh_objects = [{'type': 'release', | ||||
'id': sha1_git}] | 'id': sha1_git}] | ||||
Show All 36 Lines |