Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/private/deposit_read.py
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | def metadata_read(self, deposit): | ||||
Returns: | Returns: | ||||
Dictionary of data representing the deposit to inject in swh. | Dictionary of data representing the deposit to inject in swh. | ||||
""" | """ | ||||
metadata = self._metadata_get(deposit) | metadata = self._metadata_get(deposit) | ||||
# Read information metadata | # Read information metadata | ||||
data = {"origin": {"type": "deposit", "url": deposit.origin_url,}} | data = {"origin": {"type": "deposit", "url": deposit.origin_url,}} | ||||
# revision | |||||
fullname = deposit.client.username | |||||
author_committer = SWH_PERSON | |||||
# metadata provider | # metadata provider | ||||
self.provider["provider_name"] = deposit.client.last_name | self.provider["provider_name"] = deposit.client.last_name | ||||
self.provider["provider_url"] = deposit.client.provider_url | self.provider["provider_url"] = deposit.client.provider_url | ||||
revision_type = "tar" | |||||
revision_msg = "%s: Deposit %s in collection %s" % ( | |||||
fullname, | |||||
deposit.id, | |||||
deposit.collection.name, | |||||
) | |||||
author_date, commit_date = self._normalize_dates(deposit, metadata) | author_date, commit_date = self._normalize_dates(deposit, metadata) | ||||
data["revision"] = { | |||||
"synthetic": True, | |||||
"date": author_date, | |||||
"committer_date": commit_date, | |||||
"author": author_committer, | |||||
"committer": author_committer, | |||||
"type": revision_type, | |||||
"message": revision_msg, | |||||
"metadata": metadata, | |||||
} | |||||
if deposit.parent: | if deposit.parent: | ||||
swh_persistent_id = deposit.parent.swh_id | swh_persistent_id = deposit.parent.swh_id | ||||
persistent_identifier = identifiers.parse_persistent_identifier( | persistent_identifier = identifiers.parse_persistent_identifier( | ||||
swh_persistent_id | swh_persistent_id | ||||
) | ) | ||||
parent_revision = persistent_identifier.object_id | parent_revision = persistent_identifier.object_id | ||||
parents = [parent_revision] | |||||
else: | |||||
parents = [] | |||||
data["revision"]["parents"] = [parent_revision] | |||||
data["branch_name"] = "master" | |||||
moranegg: just checking that a branch master is still created for a deposit..
I can't see it here, but it… | |||||
Done Inline ActionsThat entry was no longer used, thus why i removed it. And it's done loader side [1] ardumont: That entry was no longer used, thus why i removed it.
It's no longer a master branch, it's HEAD… | |||||
data["origin_metadata"] = { | data["origin_metadata"] = { | ||||
"provider": self.provider, | "provider": self.provider, | ||||
"tool": self.tool, | "tool": self.tool, | ||||
"metadata": metadata, | "metadata": metadata, | ||||
} | } | ||||
data["deposit"] = { | |||||
"id": deposit.id, | |||||
"client": deposit.client.username, | |||||
"collection": deposit.collection.name, | |||||
"author": SWH_PERSON, | |||||
"author_date": author_date, | |||||
Done Inline Actions@moranegg hard-coded here in "author" and "committer" (i'm only porting the previous behavior heh). ardumont: @moranegg hard-coded here in "author" and "committer" (i'm only porting the previous behavior… | |||||
"committer": SWH_PERSON, | |||||
"committer_date": commit_date, | |||||
"revision_parents": parents, | |||||
} | |||||
return data | return data | ||||
def process_get(self, request, collection_name, deposit_id): | def process_get(self, request, collection_name, deposit_id): | ||||
deposit = Deposit.objects.get(pk=deposit_id) | deposit = Deposit.objects.get(pk=deposit_id) | ||||
data = self.metadata_read(deposit) | data = self.metadata_read(deposit) | ||||
d = {} | d = {} | ||||
if data: | if data: | ||||
d = json.dumps(data) | d = json.dumps(data) | ||||
return status.HTTP_200_OK, d, "application/json" | return status.HTTP_200_OK, d, "application/json" |
just checking that a branch master is still created for a deposit..
I can't see it here, but it may be part of the simplification..