Skip to content
Snippets Groups Projects
Verified Commit 8ffd8176 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

moderation: Fix deposit uri computation for 'code' deposits

Prior to this commit, this was done for all deposits but it's only a good fallback for
typed deposit 'code'.

Related to T4123
parent ad5add7d
No related branches found
No related tags found
No related merge requests found
......@@ -88,22 +88,27 @@ def _admin_deposit_list(request):
}
provenance = None
raw_metadata = d["raw_metadata"]
# Try to determine provenance out of the raw metadata
# for meta deposit, the uri should be the url provenance
if raw_metadata and d["type"] == "meta": # metadata provenance
provenance = parse_swh_metadata_provenance(d["raw_metadata"])
# For code deposits the uri is the origin
# First, trying to determine it out of the raw metadata associated with the
# deposit
elif raw_metadata and d["type"] == "code":
provenance = parse_swh_deposit_origin(raw_metadata)
if not provenance and d["origin_url"]:
provenance = d["origin_url"]
# For code deposits, if not provided, use the origin_url
if not provenance and d["type"] == "code":
if d["origin_url"]:
provenance = d["origin_url"]
# Finally, if still not found, we determine uri using the swhid
if not provenance and d["swhid_context"]:
# Trying to compute the origin as we did before in the js
from swh.model.swhids import QualifiedSWHID
# If still not found, fallback using the swhid context
if not provenance and d["swhid_context"]:
# Trying to compute the origin as we did before in the js
from swh.model.swhids import QualifiedSWHID
swhid = QualifiedSWHID.from_string(d["swhid_context"])
provenance = swhid.origin
swhid = QualifiedSWHID.from_string(d["swhid_context"])
provenance = swhid.origin
data_dict["uri"] = provenance # could be None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment