From 96d16a4ba2b77e2480cb949cef374e84700264bf Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Mon, 21 Aug 2023 12:28:31 +0100 Subject: [PATCH 01/11] DF-800:Added records attributes-Initial --- etna/records/field_labels.py | 3 +++ etna/records/models.py | 4 ++++ templates/includes/records/record-details.html | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/etna/records/field_labels.py b/etna/records/field_labels.py index 5c674ade8..b950e936c 100644 --- a/etna/records/field_labels.py +++ b/etna/records/field_labels.py @@ -17,4 +17,7 @@ "related_articles": "Related content", "related_materials": "Related material", "closure": "Closure Status", + "record_opening": "Record opening date", + "title": "Title", + "former_department_reference": "Former reference in its original department", } diff --git a/etna/records/models.py b/etna/records/models.py index 6d7ddd4cf..96b9f9c77 100644 --- a/etna/records/models.py +++ b/etna/records/models.py @@ -904,6 +904,10 @@ def former_name_authority_reference(self) -> str: @cached_property def closure_status(self) -> str: return extract(self.get("@template", {}), "details.closureStatus", default="") + + @cached_property + def former_department_reference(self) -> str: + return self.template.get("formerDepartmentReference", "") @dataclass diff --git a/templates/includes/records/record-details.html b/templates/includes/records/record-details.html index db805dc6a..2923ac870 100644 --- a/templates/includes/records/record-details.html +++ b/templates/includes/records/record-details.html @@ -9,6 +9,12 @@ {{ record.reference_number }} {% endif %} + {% if record.title %} + + {{ 'title'|as_label }} + {{ record.title }} + + {% endif %} {% if record.date_created %} {{ 'date_created'|as_label }} @@ -46,6 +52,12 @@ {{ record.held_by }} {% endif %} + {% if record.former_department_reference %} + + {{ 'former_department_reference'|as_label }} + {{ record.former_department_reference }} + + {% endif %} {% if record.legal_status %} {{ 'legal_status'|as_label }} @@ -64,6 +76,12 @@ {{ record.access_condition }} {% endif %} + {% if record.record_opening %} + + {{ 'record_opening'|as_label }} + {{ record.record_opening }} + + {% endif %} From 0f33428dadd06b9010c5f9040e0b370d012a2fa7 Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Mon, 21 Aug 2023 16:17:29 +0100 Subject: [PATCH 02/11] DF-DF-800:Added more records attributes --- etna/records/field_labels.py | 7 ++ etna/records/models.py | 36 +++++++++- .../includes/records/record-details.html | 65 +++++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) diff --git a/etna/records/field_labels.py b/etna/records/field_labels.py index b950e936c..bbfe78b9b 100644 --- a/etna/records/field_labels.py +++ b/etna/records/field_labels.py @@ -20,4 +20,11 @@ "record_opening": "Record opening date", "title": "Title", "former_department_reference": "Former reference in its original department", + "language": "Language", + "creator": "Creator", + "physical_description": "Physical description", + "immediate_source_of_acquisition": "Immediate source of acquisition", + "accruals": "Accruals", + "administrative_background": "Administrative/ biographical background", + "separated_materials": "Separated material", } diff --git a/etna/records/models.py b/etna/records/models.py index 96b9f9c77..8be97fff0 100644 --- a/etna/records/models.py +++ b/etna/records/models.py @@ -904,11 +904,45 @@ def former_name_authority_reference(self) -> str: @cached_property def closure_status(self) -> str: return extract(self.get("@template", {}), "details.closureStatus", default="") - + @cached_property def former_department_reference(self) -> str: return self.template.get("formerDepartmentReference", "") + @cached_property + def language(self) -> list(str): + return self.template.get("language", []) + + @cached_property + def creator(self) -> list(str): + return self.template.get("creator", []) + + @cached_property + def physical_description(self) -> str: + return self.template.get("physicalDescription", "") + + @cached_property + def immediate_source_of_acquisition(self) -> list(str): + return self.template.get("immediateSourceOfAcquisition", []) + + @cached_property + def accruals(self) -> str: + return self.template.get("accruals", "") + + @cached_property + def administrative_background(self) -> str: + return self.template.get("administrativeBackground", "") + + @cached_property + def separated_materials(self) -> Tuple[Dict[str, Any]]: + return tuple( + dict( + description=item.get("description", ""), + links=list(format_link(val) for val in item.get("links", ())), + ) + for item in self.template.get("separatedMaterials", ()) + ) + @dataclass class Image: diff --git a/templates/includes/records/record-details.html b/templates/includes/records/record-details.html index 2923ac870..8db4c5b59 100644 --- a/templates/includes/records/record-details.html +++ b/templates/includes/records/record-details.html @@ -45,6 +45,23 @@ {% endfor %} + {% endif %} + {% if record.separated_materials %} + + {{ 'separated_materials'|as_label }} + + {% for separated_material in record.separated_materials %} + {% if separated_material.description %} +

{{ separated_material.description }}

+ {% endif %} + {% if separated_material.links %} + {% for link in separated_material.links %} +

{{ link.text }}

+ {% endfor %} + {% endif %} + {% endfor %} + + {% endif %} {% if record.held_by %} @@ -64,6 +81,42 @@ {{ record.legal_status }} {% endif %} + {% if record.language %} + + {{ 'language'|as_label }} + + {% for item in record.language %} +

{{ item }}

+ {% endfor %} + + + {% endif %} + {% if record.creator %} + + {{ 'creator'|as_label }} + + {% for item in record.creator %} +

{{ item }}

+ {% endfor %} + + + {% endif %} + {% if record.physical_description %} + + {{ 'physical_description'|as_label }} + {{ record.physical_description }} + + {% endif %} + {% if record.immediate_source_of_acquisition %} + + {{ 'immediate_source_of_acquisition'|as_label }} + + {% for item in record.immediate_source_of_acquisition %} +

{{ item }}

+ {% endfor %} + + + {% endif %} {% if record.closure_status %} {{ 'closure'|as_label }} @@ -76,6 +129,18 @@ {{ record.access_condition }} {% endif %} + {% if record.accruals %} + + {{ 'accruals'|as_label }} + {{ record.accruals }} + + {% endif %} + {% if record.administrative_background %} + + {{ 'administrative_background'|as_label }} + {{ record.administrative_background }} + + {% endif %} {% if record.record_opening %} {{ 'record_opening'|as_label }} From f7cb5f5f00626c332841ab0bd7ddf2173c1c623a Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Tue, 22 Aug 2023 15:55:11 +0100 Subject: [PATCH 03/11] DF-800:Added record attributes --- etna/records/field_labels.py | 11 ++++- etna/records/models.py | 40 ++++++++++++---- .../includes/records/record-details.html | 46 +++++++++++++++++++ 3 files changed, 87 insertions(+), 10 deletions(-) diff --git a/etna/records/field_labels.py b/etna/records/field_labels.py index bbfe78b9b..ff3d5323b 100644 --- a/etna/records/field_labels.py +++ b/etna/records/field_labels.py @@ -17,14 +17,21 @@ "related_articles": "Related content", "related_materials": "Related material", "closure": "Closure Status", + "arrangement": "Arrangement", "record_opening": "Record opening date", "title": "Title", + "creator": "Creator", + "dimensions": "Dimensions", "former_department_reference": "Former reference in its original department", + "former_pro_reference": "Former reference in The National Archives", "language": "Language", - "creator": "Creator", + "map_designation": "Map designation", + "map_scale": "Map scale", + "note": "Note", + "physical_condition": "Physical condition", "physical_description": "Physical description", - "immediate_source_of_acquisition": "Immediate source of acquisition", "accruals": "Accruals", + "immediate_source_of_acquisition": "Immediate source of acquisition", "administrative_background": "Administrative/ biographical background", "separated_materials": "Separated material", } diff --git a/etna/records/models.py b/etna/records/models.py index 8be97fff0..d8fedcd62 100644 --- a/etna/records/models.py +++ b/etna/records/models.py @@ -27,7 +27,6 @@ extract, find, find_all, - format_description_markup, format_link, strip_html, ) @@ -228,7 +227,7 @@ def arrangement(self) -> str: raw = self.template["arrangement"] except KeyError: raw = self.get("arrangement.value", default="") - return format_description_markup(raw) + return mark_safe(raw) @cached_property def legal_status(self) -> str: @@ -905,30 +904,55 @@ def former_name_authority_reference(self) -> str: def closure_status(self) -> str: return extract(self.get("@template", {}), "details.closureStatus", default="") + @cached_property + def creator(self) -> list(str): + return self.template.get("creator", []) + + @cached_property + def dimensions(self) -> str: + return self.template.get("dimensions", "") + @cached_property def former_department_reference(self) -> str: return self.template.get("formerDepartmentReference", "") + @cached_property + def former_pro_reference(self) -> str: + return self.template.get("formerProReference", "") + @cached_property def language(self) -> list(str): return self.template.get("language", []) @cached_property - def creator(self) -> list(str): - return self.template.get("creator", []) + def map_designation(self) -> str: + return mark_safe(self.template.get("mapDesignation", "")) @cached_property - def physical_description(self) -> str: - return self.template.get("physicalDescription", "") + def map_scale(self) -> str: + return self.template.get("mapScale", "") @cached_property - def immediate_source_of_acquisition(self) -> list(str): - return self.template.get("immediateSourceOfAcquisition", []) + def note(self) -> list(str): + notes = [mark_safe(note) for note in self.template.get("note", [])] + return notes + + @cached_property + def physical_condition(self) -> str: + return self.template.get("physicalCondition", "") + + @cached_property + def physical_description(self) -> str: + return self.template.get("physicalDescription", "") @cached_property def accruals(self) -> str: return self.template.get("accruals", "") + @cached_property + def immediate_source_of_acquisition(self) -> list(str): + return self.template.get("immediateSourceOfAcquisition", []) + @cached_property def administrative_background(self) -> str: return self.template.get("administrativeBackground", "") diff --git a/templates/includes/records/record-details.html b/templates/includes/records/record-details.html index 8db4c5b59..774e414ea 100644 --- a/templates/includes/records/record-details.html +++ b/templates/includes/records/record-details.html @@ -27,6 +27,16 @@ {{ record.description }} {% endif %} + {% if record.note %} + + {{ 'note'|as_label }} + + {% for item in record.note %} +

{{ item }}

+ {% endfor %} + + + {% endif %} {% if record.related_materials %} {{ 'related_materials'|as_label }} @@ -62,6 +72,12 @@ {% endfor %} + {% endif %} + {% if record.arrangement %} + + {{ 'arrangement'|as_label }} + {{ record.arrangement }} + {% endif %} {% if record.held_by %} @@ -75,6 +91,12 @@ {{ record.former_department_reference }} {% endif %} + {% if record.former_pro_reference %} + + {{ 'former_pro_reference'|as_label }} + {{ record.former_pro_reference }} + + {% endif %} {% if record.legal_status %} {{ 'legal_status'|as_label }} @@ -91,6 +113,12 @@ {% endif %} + {% if record.map_designation %} + + {{ 'map_designation'|as_label }} + <{{ record.map_designation }} + + {% endif %} {% if record.creator %} {{ 'creator'|as_label }} @@ -117,6 +145,24 @@ {% endif %} + {% if record.dimensions %} + + {{ 'dimensions'|as_label }} + {{ record.dimensions }} + + {% endif %} + {% if record.map_scale %} + + {{ 'map_scale'|as_label }} + {{ record.map_scale }} + + {% endif %} + {% if record.physical_condition %} + + {{ 'physical_condition'|as_label }} + {{ record.physical_condition }} + + {% endif %} {% if record.closure_status %} {{ 'closure'|as_label }} From 0f5224cba121fb038d3091e0e4fb31c36072e799 Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Tue, 22 Aug 2023 15:55:29 +0100 Subject: [PATCH 04/11] DF-800:Added tests --- etna/records/tests/test_models.py | 186 ++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) diff --git a/etna/records/tests/test_models.py b/etna/records/tests/test_models.py index 17b7141ef..e822e9842 100644 --- a/etna/records/tests/test_models.py +++ b/etna/records/tests/test_models.py @@ -6,6 +6,7 @@ from django.conf import settings from django.test import SimpleTestCase, TestCase, override_settings from django.urls import reverse +from django.utils.safestring import SafeString import responses @@ -1115,3 +1116,188 @@ def test_archive_repository_url(self): record = self.records_client.fetch(iaid="A13532479") self.assertEqual(record.archive_repository_url, "http://nro.adlibhosting.com/") + + +class RecordModelCatalogueTests(SimpleTestCase): + + maxDiff = None + + def setUp(self): + self.source = { + "@admin": { + "id": "C123456", + }, + "source": {"value": "CAT"}, + "@template": { + "details": { + "iaid": "C123456", + } + }, + } + + def test_record_catalogue(self): + self.record = Record(self.source) + + self.assertEqual(self.record.iaid, "C123456") + self.assertEqual(self.record.custom_record_type, "CAT") + + def test_empty_for_optional_attributes(self): + self.record = Record(self.source) + + self.assertEqual(self.record.record_opening, "") + self.assertEqual(self.record.title, "") + self.assertEqual(self.record.creator, []) + self.assertEqual(self.record.dimensions, "") + self.assertEqual(self.record.former_department_reference, "") + self.assertEqual(self.record.former_pro_reference, "") + self.assertEqual(self.record.language, []) + self.assertEqual(self.record.map_designation, "") + self.assertEqual(self.record.map_scale, "") + self.assertEqual(self.record.note, []) + self.assertEqual(self.record.physical_condition, "") + self.assertEqual(self.record.physical_description, "") + self.assertEqual(self.record.accruals, "") + self.assertEqual(self.record.immediate_source_of_acquisition, []) + self.assertEqual(self.record.administrative_background, "") + self.assertEqual(self.record.separated_materials, ()) + + def test_creator(self): + self.source.update( + { + "@template": { + "details": { + "creator": ["some value 1", "some value 2"], + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.creator, ["some value 1", "some value 2"]) + + def test_dimensions(self): + self.source.update( + { + "@template": { + "details": { + "dimensions": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.dimensions, "some value") + + def test_former_department_reference(self): + self.source.update( + { + "@template": { + "details": { + "formerDepartmentReference": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.former_department_reference, "some value") + + def test_former_pro_reference(self): + self.source.update( + { + "@template": { + "details": { + "formerProReference": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.former_pro_reference, "some value") + + def test_language(self): + self.source.update( + { + "@template": { + "details": { + "language": ["some value 1", "some value 2"], + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.language, ["some value 1", "some value 2"]) + + def test_map_designation(self): + + self.source.update( + { + "@template": { + "details": { + "mapDesignation": 'some value', + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual( + self.record.map_designation, + 'some value', + ) + self.assertTrue(isinstance(self.record.map_designation, SafeString)) + + def test_map_scale(self): + + self.source.update( + { + "@template": { + "details": { + "mapScale": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.map_scale, "some value") + + def test_note(self): + self.source.update( + { + "@template": { + "details": { + "note": [ + "Details have been added from C 32/18, which also gives information about further process.

", + ], + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual( + self.record.note, + [ + "Details have been added from C 32/18, which also gives information about further process.

" + ], + ) + self.assertTrue(isinstance(self.record.note[0], SafeString)) + + def test_physical_description(self): + + self.source.update( + { + "@template": { + "details": { + "physicalDescription": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.physical_description, "some value") From 49c6778fde9f26da07fd070837cd4786eb21831b Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Thu, 24 Aug 2023 09:32:03 +0100 Subject: [PATCH 05/11] DF-800:Added record attrs and tests --- etna/records/field_labels.py | 3 + etna/records/models.py | 29 ++++- etna/records/tests/test_models.py | 110 ++++++++++++++++++ .../includes/records/record-details.html | 30 ++++- 4 files changed, 170 insertions(+), 2 deletions(-) diff --git a/etna/records/field_labels.py b/etna/records/field_labels.py index ff3d5323b..2b119ccb8 100644 --- a/etna/records/field_labels.py +++ b/etna/records/field_labels.py @@ -31,7 +31,10 @@ "physical_condition": "Physical condition", "physical_description": "Physical description", "accruals": "Accruals", + "accumulation_dates": "Accumulation dates", + "appraisal_information": "Selection and destruction information", "immediate_source_of_acquisition": "Immediate source of acquisition", "administrative_background": "Administrative/ biographical background", "separated_materials": "Separated material", + "unpublished_finding_aids": "Unpublished finding aids", } diff --git a/etna/records/models.py b/etna/records/models.py index d8fedcd62..dc0c0b21f 100644 --- a/etna/records/models.py +++ b/etna/records/models.py @@ -301,6 +301,21 @@ def _get_raw_content(self) -> str: def held_by(self) -> str: return self.template.get("heldBy", "") + @cached_property + def held_by_id(self) -> str: + return self.template.get("heldById", "") + + @cached_property + def held_by_url(self) -> str: + if self.held_by_id: + try: + return reverse( + "details-page-machine-readable", kwargs={"iaid": self.held_by_id} + ) + except NoReverseMatch: + pass + return "" + @cached_property def date_created(self) -> str: return self.template.get("dateCreated", "") @@ -500,7 +515,7 @@ def get_datalayer_data(self, request: HttpRequest) -> Dict[str, Any]: @cached_property def title(self) -> str: - return self.template.get("title", "") + return mark_safe(self.template.get("title", "")) @cached_property def archive_contact_info(self) -> Optional[ContactInfo]: @@ -949,6 +964,14 @@ def physical_description(self) -> str: def accruals(self) -> str: return self.template.get("accruals", "") + @cached_property + def accumulation_dates(self) -> str: + return self.template.get("accumulationDates", "") + + @cached_property + def appraisal_information(self) -> str: + return self.template.get("appraisalInformation", "") + @cached_property def immediate_source_of_acquisition(self) -> list(str): return self.template.get("immediateSourceOfAcquisition", []) @@ -967,6 +990,10 @@ def separated_materials(self) -> Tuple[Dict[str, Any]]: for item in self.template.get("separatedMaterials", ()) ) + @cached_property + def unpublished_finding_aids(self) -> list(str): + return self.template.get("unpublishedFindingAids", []) + @dataclass class Image: diff --git a/etna/records/tests/test_models.py b/etna/records/tests/test_models.py index e822e9842..1e8861d21 100644 --- a/etna/records/tests/test_models.py +++ b/etna/records/tests/test_models.py @@ -1144,6 +1144,8 @@ def test_record_catalogue(self): def test_empty_for_optional_attributes(self): self.record = Record(self.source) + self.assertEqual(self.record.held_by_id, "") + self.assertEqual(self.record.held_by_url, "") self.assertEqual(self.record.record_opening, "") self.assertEqual(self.record.title, "") self.assertEqual(self.record.creator, []) @@ -1161,6 +1163,53 @@ def test_empty_for_optional_attributes(self): self.assertEqual(self.record.administrative_background, "") self.assertEqual(self.record.separated_materials, ()) + def test_held_by_url_attrs(self): + self.source.update( + { + "@template": { + "details": { + "heldById": "A13530124", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.held_by_id, "A13530124") + self.assertEqual(self.record.held_by_url, "/catalogue/id/A13530124/") + + def test_record_opening(self): + self.source.update( + { + "@template": { + "details": { + "recordOpening": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.record_opening, "some value") + + def test_title(self): + self.source.update( + { + "@template": { + "details": { + "title": 'Records of the General Register Office, Government Social Survey Department, and Office of Population Censuses and Surveys', + } + }, + } + ) + self.record = Record(self.source) + + self.assertTrue(isinstance(self.record.title, SafeString)) + self.assertEqual( + self.record.title, + 'Records of the General Register Office, Government Social Survey Department, and Office of Population Censuses and Surveys', + ) + def test_creator(self): self.source.update( { @@ -1287,6 +1336,21 @@ def test_note(self): ) self.assertTrue(isinstance(self.record.note[0], SafeString)) + def test_physical_condition(self): + + self.source.update( + { + "@template": { + "details": { + "physicalCondition": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.physical_condition, "some value") + def test_physical_description(self): self.source.update( @@ -1301,3 +1365,49 @@ def test_physical_description(self): self.record = Record(self.source) self.assertEqual(self.record.physical_description, "some value") + + def test_accruals(self): + + self.source.update( + { + "@template": { + "details": { + "accruals": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.accruals, "some value") + + def test_accumulation_dates(self): + + self.source.update( + { + "@template": { + "details": { + "accumulationDates": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.accumulation_dates, "some value") + + def test_unpublished_finding_aids(self): + self.source.update( + { + "@template": { + "details": { + "unpublishedFindingAids": ["some value 1", "some value 2"], + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual( + self.record.unpublished_finding_aids, ["some value 1", "some value 2"] + ) diff --git a/templates/includes/records/record-details.html b/templates/includes/records/record-details.html index 774e414ea..d6ebe233f 100644 --- a/templates/includes/records/record-details.html +++ b/templates/includes/records/record-details.html @@ -82,7 +82,13 @@ {% if record.held_by %} {{ 'held_by'|as_label }} - {{ record.held_by }} + + {% if record.held_by_url %} + {{ record.held_by }} + {% else %} + {{ record.held_by }} + {% endif %} + {% endif %} {% if record.former_department_reference %} @@ -175,12 +181,34 @@ {{ record.access_condition }} {% endif %} + {% if record.accumulation_dates %} + + {{ 'accumulation_dates'|as_label }} + {{ record.accumulation_dates }} + + {% endif %} {% if record.accruals %} {{ 'accruals'|as_label }} {{ record.accruals }} {% endif %} + {% if record.unpublished_finding_aids %} + + {{ 'unpublished_finding_aids'|as_label }} + + {% for item in record.unpublished_finding_aids %} +

{{ item }}

+ {% endfor %} + + + {% endif %} + {% if record.appraisal_information %} + + {{ 'appraisal_information'|as_label }} + {{ record.appraisal_information }} + + {% endif %} {% if record.administrative_background %} {{ 'administrative_background'|as_label }} From 31884506400d843ac8eb6516862c3732278d039f Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Fri, 25 Aug 2023 13:28:30 +0100 Subject: [PATCH 06/11] DF-800:Added record attrs and tests --- etna/records/field_labels.py | 5 + etna/records/models.py | 22 +- etna/records/tests/test_models.py | 209 ++++++++++++++++++ .../includes/records/record-details.html | 60 ++++- 4 files changed, 286 insertions(+), 10 deletions(-) diff --git a/etna/records/field_labels.py b/etna/records/field_labels.py index 2b119ccb8..2cea07e48 100644 --- a/etna/records/field_labels.py +++ b/etna/records/field_labels.py @@ -37,4 +37,9 @@ "administrative_background": "Administrative/ biographical background", "separated_materials": "Separated material", "unpublished_finding_aids": "Unpublished finding aids", + "copies_information": "Copies information", + "custodial_history": "Custodial history", + "location_of_originals": "Originals held at", + "restrictions_on_use": "Restrictions on use", + "publication_note": "Publication note", } diff --git a/etna/records/models.py b/etna/records/models.py index dc0c0b21f..a8033909e 100644 --- a/etna/records/models.py +++ b/etna/records/models.py @@ -978,7 +978,7 @@ def immediate_source_of_acquisition(self) -> list(str): @cached_property def administrative_background(self) -> str: - return self.template.get("administrativeBackground", "") + return mark_safe(self.template.get("administrativeBackground", "")) @cached_property def separated_materials(self) -> Tuple[Dict[str, Any]]: @@ -994,6 +994,26 @@ def separated_materials(self) -> Tuple[Dict[str, Any]]: def unpublished_finding_aids(self) -> list(str): return self.template.get("unpublishedFindingAids", []) + @cached_property + def copies_information(self) -> list(str): + return self.template.get("copiesInformation", []) + + @cached_property + def custodial_history(self) -> str: + return self.template.get("custodialHistory", "") + + @cached_property + def location_of_originals(self) -> list(str): + return self.template.get("locationOfOriginals", []) + + @cached_property + def restrictions_on_use(self) -> str: + return self.template.get("restrictionsOnUse", "") + + @cached_property + def publication_note(self) -> list(str): + return self.template.get("publicationNote", []) + @dataclass class Image: diff --git a/etna/records/tests/test_models.py b/etna/records/tests/test_models.py index 1e8861d21..27893510b 100644 --- a/etna/records/tests/test_models.py +++ b/etna/records/tests/test_models.py @@ -1144,6 +1144,7 @@ def test_record_catalogue(self): def test_empty_for_optional_attributes(self): self.record = Record(self.source) + self.assertEqual(self.record.arrangement, "") self.assertEqual(self.record.held_by_id, "") self.assertEqual(self.record.held_by_url, "") self.assertEqual(self.record.record_opening, "") @@ -1159,9 +1160,17 @@ def test_empty_for_optional_attributes(self): self.assertEqual(self.record.physical_condition, "") self.assertEqual(self.record.physical_description, "") self.assertEqual(self.record.accruals, "") + self.assertEqual(self.record.accumulation_dates, "") + self.assertEqual(self.record.appraisal_information, "") self.assertEqual(self.record.immediate_source_of_acquisition, []) self.assertEqual(self.record.administrative_background, "") self.assertEqual(self.record.separated_materials, ()) + self.assertEqual(self.record.unpublished_finding_aids, []) + self.assertEqual(self.record.copies_information, []) + self.assertEqual(self.record.custodial_history, "") + self.assertEqual(self.record.location_of_originals, []) + self.assertEqual(self.record.restrictions_on_use, "") + self.assertEqual(self.record.publication_note, []) def test_held_by_url_attrs(self): self.source.update( @@ -1178,6 +1187,24 @@ def test_held_by_url_attrs(self): self.assertEqual(self.record.held_by_id, "A13530124") self.assertEqual(self.record.held_by_url, "/catalogue/id/A13530124/") + def test_arrangement(self): + self.source.update( + { + "@template": { + "details": { + "arrangement": "

Former reference order within two accessions (AN 171/1-648 and AN 171/649-970).

", + } + }, + } + ) + self.record = Record(self.source) + + self.assertTrue(isinstance(self.record.arrangement, SafeString)) + self.assertEqual( + self.record.arrangement, + "

Former reference order within two accessions (AN 171/1-648 and AN 171/649-970).

", + ) + def test_record_opening(self): self.source.update( { @@ -1396,6 +1423,113 @@ def test_accumulation_dates(self): self.assertEqual(self.record.accumulation_dates, "some value") + def test_appraisal_information(self): + + self.source.update( + { + "@template": { + "details": { + "appraisalInformation": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.appraisal_information, "some value") + + def test_immediate_source_of_acquisition(self): + self.source.update( + { + "@template": { + "details": { + "immediateSourceOfAcquisition": [ + "some value 1", + "some value 2", + ], + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual( + self.record.immediate_source_of_acquisition, + ["some value 1", "some value 2"], + ) + + def test_administrative_background(self): + + self.source.update( + { + "@template": { + "details": { + "administrativeBackground": "

The Industrial Relations Department was set up as soon as the British Transport Commission began functioning and continued in existence until the end of the British Railway Board. In 1983 it was renamed Employee Relations Department.

", + } + }, + } + ) + self.record = Record(self.source) + + self.assertTrue(isinstance(self.record.administrative_background, SafeString)) + self.assertEqual( + self.record.administrative_background, + "

The Industrial Relations Department was set up as soon as the British Transport Commission began functioning and continued in existence until the end of the British Railway Board. In 1983 it was renamed Employee Relations Department.

", + ) + + def test_separated_materials(self): + self.source.update( + { + "@template": { + "details": { + "separatedMaterials": [ + { + "description": "for 4 maps extracted from this item see", + "links": [ + 'MFQ 1/761/7', + 'MFQ 1/761/6', + 'MFQ 1/761/5', + 'MFQ 1/761/4', + ], + } + ], + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual( + self.record.separated_materials, + ( + { + "description": "for 4 maps extracted from this item see", + "links": [ + { + "href": "/catalogue/id/C8956177/", + "id": "C8956177", + "text": "MFQ 1/761/7", + }, + { + "href": "/catalogue/id/C8956176/", + "id": "C8956176", + "text": "MFQ 1/761/6", + }, + { + "href": "/catalogue/id/C8956175/", + "id": "C8956175", + "text": "MFQ 1/761/5", + }, + { + "href": "/catalogue/id/C8956174/", + "id": "C8956174", + "text": "MFQ 1/761/4", + }, + ], + }, + ), + ) + def test_unpublished_finding_aids(self): self.source.update( { @@ -1411,3 +1545,78 @@ def test_unpublished_finding_aids(self): self.assertEqual( self.record.unpublished_finding_aids, ["some value 1", "some value 2"] ) + + def test_copies_information(self): + self.source.update( + { + "@template": { + "details": { + "copiesInformation": ["some value 1", "some value 2"], + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual( + self.record.copies_information, ["some value 1", "some value 2"] + ) + + def test_custodial_history(self): + + self.source.update( + { + "@template": { + "details": { + "custodialHistory": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.custodial_history, "some value") + + def test_location_of_originals(self): + self.source.update( + { + "@template": { + "details": { + "locationOfOriginals": ["some value 1", "some value 2"], + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual( + self.record.location_of_originals, ["some value 1", "some value 2"] + ) + + def test_restrictions_on_use(self): + self.source.update( + { + "@template": { + "details": { + "restrictionsOnUse": "some value", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.restrictions_on_use, "some value") + + def test_lpublication_note(self): + self.source.update( + { + "@template": { + "details": { + "publicationNote": ["some value 1", "some value 2"], + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual(self.record.publication_note, ["some value 1", "some value 2"]) diff --git a/templates/includes/records/record-details.html b/templates/includes/records/record-details.html index d6ebe233f..8731b02e7 100644 --- a/templates/includes/records/record-details.html +++ b/templates/includes/records/record-details.html @@ -36,6 +36,12 @@ {% endfor %} + {% endif %} + {% if record.arrangement %} + + {{ 'arrangement'|as_label }} + {{ record.arrangement }} + {% endif %} {% if record.related_materials %} @@ -72,12 +78,6 @@ {% endfor %} - {% endif %} - {% if record.arrangement %} - - {{ 'arrangement'|as_label }} - {{ record.arrangement }} - {% endif %} {% if record.held_by %} @@ -103,6 +103,16 @@ {{ record.former_pro_reference }} {% endif %} + {% if record.location_of_originals %} + + {{ 'location_of_originals'|as_label }} + + {% for item in record.location_of_originals %} +

{{ item }}

+ {% endfor %} + + + {% endif %} {% if record.legal_status %} {{ 'legal_status'|as_label }} @@ -141,6 +151,12 @@ {{ record.physical_description }} {% endif %} + {% if record.access_condition %} + + {{ 'access_condition'|as_label }} + {{ record.access_condition }} + + {% endif %} {% if record.immediate_source_of_acquisition %} {{ 'immediate_source_of_acquisition'|as_label }} @@ -174,11 +190,17 @@ {{ 'closure'|as_label }} {{ record.closure_status }} + {% endif %} + {% if record.restrictions_on_use %} + + {{ 'restrictions_on_use'|as_label }} + {{ record.restrictions_on_use }} + {% endif %} - {% if record.access_condition %} + {% if record.custodial_history %} - {{ 'access_condition'|as_label }} - {{ record.access_condition }} + {{ 'custodial_history'|as_label }} + {{ record.custodial_history }} {% endif %} {% if record.accumulation_dates %} @@ -215,6 +237,26 @@ {{ record.administrative_background }} {% endif %} + {% if record.copies_information %} + + {{ 'copies_information'|as_label }} + + {% for item in record.copies_information %} +

{{ item }}

+ {% endfor %} + + + {% endif %} + {% if record.publication_note %} + + {{ 'publication_note'|as_label }} + + {% for item in record.publication_note %} +

{{ item }}

+ {% endfor %} + + + {% endif %} {% if record.record_opening %} {{ 'record_opening'|as_label }} From 9d5154cb94564f5b8fdfd6d03c263041694aae0f Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Fri, 25 Aug 2023 16:57:12 +0100 Subject: [PATCH 07/11] DF-800:Added deliveryOption attr --- etna/records/field_labels.py | 1 + etna/records/models.py | 4 ++++ etna/records/tests/test_models.py | 20 ++++++++++++++++++- .../includes/records/record-details.html | 6 ++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/etna/records/field_labels.py b/etna/records/field_labels.py index 2cea07e48..3862caa3a 100644 --- a/etna/records/field_labels.py +++ b/etna/records/field_labels.py @@ -42,4 +42,5 @@ "location_of_originals": "Originals held at", "restrictions_on_use": "Restrictions on use", "publication_note": "Publication note", + "delivery_option": "Delivery option", } diff --git a/etna/records/models.py b/etna/records/models.py index a8033909e..882554ae0 100644 --- a/etna/records/models.py +++ b/etna/records/models.py @@ -1014,6 +1014,10 @@ def restrictions_on_use(self) -> str: def publication_note(self) -> list(str): return self.template.get("publicationNote", []) + @cached_property + def delivery_option(self) -> str: + return self.template.get("deliveryOption", "") + @dataclass class Image: diff --git a/etna/records/tests/test_models.py b/etna/records/tests/test_models.py index 27893510b..9de8cdafb 100644 --- a/etna/records/tests/test_models.py +++ b/etna/records/tests/test_models.py @@ -1171,6 +1171,7 @@ def test_empty_for_optional_attributes(self): self.assertEqual(self.record.location_of_originals, []) self.assertEqual(self.record.restrictions_on_use, "") self.assertEqual(self.record.publication_note, []) + self.assertEqual(self.record.delivery_option, "") def test_held_by_url_attrs(self): self.source.update( @@ -1607,7 +1608,7 @@ def test_restrictions_on_use(self): self.assertEqual(self.record.restrictions_on_use, "some value") - def test_lpublication_note(self): + def test_publication_note(self): self.source.update( { "@template": { @@ -1620,3 +1621,20 @@ def test_lpublication_note(self): self.record = Record(self.source) self.assertEqual(self.record.publication_note, ["some value 1", "some value 2"]) + + def test_delivery_option(self): + self.source.update( + { + "@template": { + "details": { + "deliveryOption": "No availability condition provisioned for this record", + } + }, + } + ) + self.record = Record(self.source) + + self.assertEqual( + self.record.delivery_option, + "No availability condition provisioned for this record", + ) diff --git a/templates/includes/records/record-details.html b/templates/includes/records/record-details.html index 8731b02e7..a633ffe1c 100644 --- a/templates/includes/records/record-details.html +++ b/templates/includes/records/record-details.html @@ -262,6 +262,12 @@ {{ 'record_opening'|as_label }} {{ record.record_opening }} + {% endif %} + {% if record.delivery_option %} + + {{ 'delivery_option'|as_label }} + {{ record.delivery_option }} + {% endif %} From 099b28afe3659233aabcb3fec808e2b243e84bcb Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Fri, 25 Aug 2023 17:01:19 +0100 Subject: [PATCH 08/11] DF-800:Updated related_materials template layout --- templates/includes/records/record-details.html | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/templates/includes/records/record-details.html b/templates/includes/records/record-details.html index a633ffe1c..fb637f57a 100644 --- a/templates/includes/records/record-details.html +++ b/templates/includes/records/record-details.html @@ -49,14 +49,13 @@ {% for related_material in record.related_materials %} {% if related_material.description %} -

{{related_material.description}}

- {% endif %} - {% if related_material.links %} -
    +

    {{related_material.description}} + {% if related_material.links %} {% for link in related_material.links %} -

  • {{ link.text }}
  • + {{ link.text }} {% endfor %} -
+ {% endif %} +

{% endif %} {% endfor %} From 1a87893e1dd265f8e44cdf7abdac6155f1895b88 Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Fri, 25 Aug 2023 17:06:34 +0100 Subject: [PATCH 09/11] DF-800:Removed redifintion for deliveryOption attr --- etna/records/models.py | 4 ---- templates/includes/records/record-details.html | 6 ------ 2 files changed, 10 deletions(-) diff --git a/etna/records/models.py b/etna/records/models.py index 882554ae0..a8033909e 100644 --- a/etna/records/models.py +++ b/etna/records/models.py @@ -1014,10 +1014,6 @@ def restrictions_on_use(self) -> str: def publication_note(self) -> list(str): return self.template.get("publicationNote", []) - @cached_property - def delivery_option(self) -> str: - return self.template.get("deliveryOption", "") - @dataclass class Image: diff --git a/templates/includes/records/record-details.html b/templates/includes/records/record-details.html index fb637f57a..3e3f84220 100644 --- a/templates/includes/records/record-details.html +++ b/templates/includes/records/record-details.html @@ -261,12 +261,6 @@ {{ 'record_opening'|as_label }} {{ record.record_opening }} - {% endif %} - {% if record.delivery_option %} - - {{ 'delivery_option'|as_label }} - {{ record.delivery_option }} - {% endif %} From 2053ecec3af984c984d4b6ffd927762dd807630c Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Fri, 25 Aug 2023 17:09:20 +0100 Subject: [PATCH 10/11] DF-800:Removed redifintion for deliveryOption attr --- etna/records/field_labels.py | 1 - 1 file changed, 1 deletion(-) diff --git a/etna/records/field_labels.py b/etna/records/field_labels.py index 3862caa3a..2cea07e48 100644 --- a/etna/records/field_labels.py +++ b/etna/records/field_labels.py @@ -42,5 +42,4 @@ "location_of_originals": "Originals held at", "restrictions_on_use": "Restrictions on use", "publication_note": "Publication note", - "delivery_option": "Delivery option", } From d124960be6fc46a53fb1fe64bedf45cf81269be7 Mon Sep 17 00:00:00 2001 From: TNA_Allan Date: Fri, 25 Aug 2023 17:15:05 +0100 Subject: [PATCH 11/11] DF-800:lint(black) update) --- etna/records/tests/test_models.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/etna/records/tests/test_models.py b/etna/records/tests/test_models.py index 9de8cdafb..c6b12b0dd 100644 --- a/etna/records/tests/test_models.py +++ b/etna/records/tests/test_models.py @@ -1119,7 +1119,6 @@ def test_archive_repository_url(self): class RecordModelCatalogueTests(SimpleTestCase): - maxDiff = None def setUp(self): @@ -1309,7 +1308,6 @@ def test_language(self): self.assertEqual(self.record.language, ["some value 1", "some value 2"]) def test_map_designation(self): - self.source.update( { "@template": { @@ -1328,7 +1326,6 @@ def test_map_designation(self): self.assertTrue(isinstance(self.record.map_designation, SafeString)) def test_map_scale(self): - self.source.update( { "@template": { @@ -1365,7 +1362,6 @@ def test_note(self): self.assertTrue(isinstance(self.record.note[0], SafeString)) def test_physical_condition(self): - self.source.update( { "@template": { @@ -1380,7 +1376,6 @@ def test_physical_condition(self): self.assertEqual(self.record.physical_condition, "some value") def test_physical_description(self): - self.source.update( { "@template": { @@ -1395,7 +1390,6 @@ def test_physical_description(self): self.assertEqual(self.record.physical_description, "some value") def test_accruals(self): - self.source.update( { "@template": { @@ -1410,7 +1404,6 @@ def test_accruals(self): self.assertEqual(self.record.accruals, "some value") def test_accumulation_dates(self): - self.source.update( { "@template": { @@ -1425,7 +1418,6 @@ def test_accumulation_dates(self): self.assertEqual(self.record.accumulation_dates, "some value") def test_appraisal_information(self): - self.source.update( { "@template": { @@ -1460,7 +1452,6 @@ def test_immediate_source_of_acquisition(self): ) def test_administrative_background(self): - self.source.update( { "@template": { @@ -1564,7 +1555,6 @@ def test_copies_information(self): ) def test_custodial_history(self): - self.source.update( { "@template": {