diff --git a/app/records/schemas/details.py b/app/records/schemas/details.py index 4b45306..f5c22f8 100644 --- a/app/records/schemas/details.py +++ b/app/records/schemas/details.py @@ -18,9 +18,12 @@ class Record(Details): type: str = "record" ref: str | None = None title: str = "" + description: str = "" date: str = "" is_digitised: bool | None = None held_by: dict | None = None + legal_status: str | None = None + closure_status: str | None = None def __init__(self, id: str): super().__init__(id) diff --git a/app/sources/rosetta/api.py b/app/sources/rosetta/api.py index 089af96..7c70b4b 100644 --- a/app/sources/rosetta/api.py +++ b/app/sources/rosetta/api.py @@ -88,9 +88,12 @@ def parse_results(self, raw_results): record = Record(parsed_data.id()) record.ref = parsed_data.identifier() record.title = parsed_data.title() + record.description = parsed_data.description() record.date = parsed_data.date_range() record.is_digitised = parsed_data.is_digitised() record.held_by = parsed_data.held_by() + record.legal_status = parsed_data.legal_status() + record.closure_status = parsed_data.closure_status() return record.toJSON() if ( parsed_data.type() == "archive" diff --git a/app/sources/rosetta/lib/response_parser.py b/app/sources/rosetta/lib/response_parser.py index d1c697c..1724509 100644 --- a/app/sources/rosetta/lib/response_parser.py +++ b/app/sources/rosetta/lib/response_parser.py @@ -273,7 +273,10 @@ def description(self) -> str: None, ): if "value" in description: - return self.strip_scope_and_content(description["value"]) + return description["value"] + return self.strip_scope_and_content( + description["value"] + ) # TODO: Breaks on C17371160 elif ( "ephemera" in description and "value" in description["ephemera"] @@ -473,3 +476,20 @@ def held_by(self) -> dict: if id and name: return {"id": id, "name": name} return {} + + def legal_status(self) -> str: + return ( + self.source["legal"]["status"] + if "legal" in self.source and "status" in self.source["legal"] + else "" + ) + + def closure_status(self) -> str: + return ( + self.source["availability"]["closure"]["label"]["value"] + if "availability" in self.source + and "closure" in self.source["availability"] + and "label" in self.source["availability"]["closure"] + and "value" in self.source["availability"]["closure"]["label"] + else "" + )