Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
Fix related_materials notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Feb 12, 2024
1 parent 8e9e413 commit 07f21af
Showing 1 changed file with 34 additions and 22 deletions.
56 changes: 34 additions & 22 deletions app/sources/rosetta/lib/response_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,28 +812,40 @@ def related_materials(self) -> list[dict]:
related_materials = []
if "related" in self.source:
for item in self.source["related"]:
id = objects.get(item, "@admin.id")
title = objects.get(item, "summary.title")
note = objects.get(item, "@link.note.value")
related_material = {
"id": id,
"title": title,
"ref": None,
"note": note,
}
if "identifier" in item:
if reference_number := next(
(
identifier["value"]
for identifier in item["identifier"]
if "value" in identifier
and "type" in identifier
and identifier["type"] == "reference number"
),
None,
):
related_material["ref"] = reference_number
related_materials.append(related_material)
if "@entity" in item and item["@entity"] == "literal":
if note := objects.get(item, "@link.note.value"):
related_materials.append(
{
"id": None,
"title": None,
"ref": None,
"note": note,
}
)
for item in self.source["related"]:
if "@entity" in item and item["@entity"] == "reference":
id = objects.get(item, "@admin.id")
title = objects.get(item, "summary.title")
note = objects.get(item, "@link.note.value")
related_material = {
"id": id,
"title": title,
"ref": None,
"note": note,
}
if "identifier" in item:
if reference_number := next(
(
identifier["value"]
for identifier in item["identifier"]
if "value" in identifier
and "type" in identifier
and identifier["type"] == "reference number"
),
None,
):
related_material["ref"] = reference_number
related_materials.append(related_material)
return related_materials

def unpublished_finding_aids(self) -> str | None:
Expand Down

0 comments on commit 07f21af

Please sign in to comment.