Page MenuHomeSoftware Heritage

D3094.diff
No OneTemporary

D3094.diff

diff --git a/swh/web/browse/views/release.py b/swh/web/browse/views/release.py
--- a/swh/web/browse/views/release.py
+++ b/swh/web/browse/views/release.py
@@ -6,6 +6,7 @@
from django.shortcuts import render
import sentry_sdk
+from swh.model.identifiers import CONTENT, DIRECTORY, RELEASE, REVISION, SNAPSHOT
from swh.web.browse.browseurls import browse_route
from swh.web.browse.snapshot_context import get_snapshot_context
from swh.web.browse.utils import (
@@ -20,6 +21,7 @@
)
from swh.web.common import service
from swh.web.common.exc import NotFoundExc, handle_view_exception
+from swh.web.common.typing import ReleaseMetadata
from swh.web.common.utils import reverse, format_utc_iso_date
@@ -37,7 +39,7 @@
"""
try:
release = service.lookup_release(sha1_git)
- snapshot_context = None
+ snapshot_context = {}
origin_info = None
snapshot_id = request.GET.get("snapshot_id", None)
origin_url = request.GET.get("origin_url", None)
@@ -69,35 +71,40 @@
except Exception as exc:
return handle_view_exception(request, exc)
- release_data = {}
-
- release_data["author"] = "None"
- if release["author"]:
- release_data["author"] = gen_person_mail_link(release["author"])
- release_data["date"] = format_utc_iso_date(release["date"])
- release_data["release"] = sha1_git
- release_data["name"] = release["name"]
- release_data["synthetic"] = release["synthetic"]
- release_data["target"] = release["target"]
- release_data["target type"] = release["target_type"]
-
+ target_url = None
+ if release["target_type"] == REVISION:
+ target_url = gen_revision_link(release["target"])
+ elif release["target_type"] == CONTENT:
+ target_url = gen_content_link(release["target"])
+ elif release["target_type"] == DIRECTORY:
+ target_url = gen_directory_link(release["target"])
+ elif release["target_type"] == RELEASE:
+ target_url = gen_release_link(release["target"])
+
+ snapshot_id = None
+ browse_snp_link = None
if snapshot_context:
- if release["target_type"] == "revision":
- release_data["context-independent target"] = gen_revision_link(
- release["target"]
- )
- elif release["target_type"] == "content":
- release_data["context-independent target"] = gen_content_link(
- release["target"]
- )
- elif release["target_type"] == "directory":
- release_data["context-independent target"] = gen_directory_link(
- release["target"]
- )
- elif release["target_type"] == "release":
- release_data["context-independent target"] = gen_release_link(
- release["target"]
- )
+ snapshot_id = snapshot_context["snapshot_id"]
+ browse_snp_link = gen_snapshot_link(snapshot_id)
+
+ release_metadata = ReleaseMetadata(
+ object_type=RELEASE,
+ release=sha1_git,
+ release_url=gen_release_link(release["id"]),
+ author=release["author"]["fullname"] if release["author"] else "None",
+ author_url=gen_person_mail_link(release["author"])
+ if release["author"]
+ else "None",
+ date=format_utc_iso_date(release["date"]),
+ name=release["name"],
+ synthetic=release["synthetic"],
+ target=release["target"],
+ target_type=release["target_type"],
+ target_url=target_url,
+ snapshot=snapshot_context.get("snapshot_id", None),
+ snapshot_url=browse_snp_link,
+ origin_url=origin_url,
+ )
release_note_lines = []
if release["message"]:
@@ -107,7 +114,7 @@
rev_directory = None
target_link = None
- if release["target_type"] == "revision":
+ if release["target_type"] == REVISION:
target_link = gen_revision_link(
release["target"],
snapshot_context=snapshot_context,
@@ -125,7 +132,7 @@
}
except Exception as exc:
sentry_sdk.capture_exception(exc)
- elif release["target_type"] == "directory":
+ elif release["target_type"] == DIRECTORY:
target_link = gen_directory_link(
release["target"],
snapshot_context=snapshot_context,
@@ -143,14 +150,14 @@
}
except Exception as exc:
sentry_sdk.capture_exception(exc)
- elif release["target_type"] == "content":
+ elif release["target_type"] == CONTENT:
target_link = gen_content_link(
release["target"],
snapshot_context=snapshot_context,
link_text=None,
link_attrs=None,
)
- elif release["target_type"] == "release":
+ elif release["target_type"] == RELEASE:
target_link = gen_release_link(
release["target"],
snapshot_context=snapshot_context,
@@ -185,22 +192,13 @@
release["directory_link"] = directory_link
release["target_link"] = target_link
- if snapshot_context:
- release_data["snapshot"] = snapshot_context["snapshot_id"]
-
- if origin_info:
- release_data["context-independent release"] = gen_release_link(release["id"])
- release_data["origin url"] = gen_link(origin_info["url"], origin_info["url"])
- browse_snapshot_link = gen_snapshot_link(snapshot_context["snapshot_id"])
- release_data["context-independent snapshot"] = browse_snapshot_link
-
- swh_objects = [{"type": "release", "id": sha1_git}]
+ swh_objects = [{"type": RELEASE, "id": sha1_git}]
if snapshot_context:
snapshot_id = snapshot_context["snapshot_id"]
if snapshot_id:
- swh_objects.append({"type": "snapshot", "id": snapshot_id})
+ swh_objects.append({"type": SNAPSHOT, "id": snapshot_id})
swh_ids = get_swh_persistent_ids(swh_objects, snapshot_context)
@@ -225,7 +223,7 @@
"heading": heading,
"swh_object_id": swh_ids[0]["swh_id"],
"swh_object_name": "Release",
- "swh_object_metadata": release_data,
+ "swh_object_metadata": release_metadata,
"release": release,
"snapshot_context": snapshot_context,
"show_actions_menu": True,
diff --git a/swh/web/common/typing.py b/swh/web/common/typing.py
--- a/swh/web/common/typing.py
+++ b/swh/web/common/typing.py
@@ -152,3 +152,16 @@
revision_found: Optional[bool]
release: Optional[str]
snapshot: Optional[str]
+
+
+class ReleaseMetadata(SWHObjectMetadata):
+ release: str
+ author: str
+ author_url: str
+ date: str
+ name: str
+ synthetic: bool
+ target: str
+ target_type: str
+ target_url: str
+ snapshot: Optional[str]
diff --git a/swh/web/templates/browse/release.html b/swh/web/templates/browse/release.html
--- a/swh/web/templates/browse/release.html
+++ b/swh/web/templates/browse/release.html
@@ -13,7 +13,7 @@
{% include "includes/top-navigation.html" %}
<div style="height: 35px;margin: 4px;">
<i class="{{ swh_object_icons.release }} fa-fw"></i>Release <b>{{ swh_object_metadata.name }}</b>
- created by {{ swh_object_metadata.author }} on <b>{{ swh_object_metadata.date }}</b>
+ created by {{ swh_object_metadata.author_url }} on <b>{{ swh_object_metadata.date }}</b>
</div>
<pre style="white-space: pre-wrap">
<h6>{{ release.note_header }}</h6>{{ release.note_body }}

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 17, 3:00 PM (2 d, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216683

Event Timeline