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

Commit

Permalink
Add legal and closure status
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Jan 12, 2024
1 parent 7e7b51b commit cf5e937
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/records/schemas/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions app/sources/rosetta/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 21 additions & 1 deletion app/sources/rosetta/lib/response_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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 ""
)

0 comments on commit cf5e937

Please sign in to comment.