From 875bfd06e1c650b94f01036258da8b0c907bd326 Mon Sep 17 00:00:00 2001 From: Andy Kohler Date: Wed, 12 Jun 2024 13:56:58 -0800 Subject: [PATCH] SYS-1637: Remove master file URLs from OAI feed (#134) --- charts/prod-ohstaff-values.yaml | 2 +- oh_staff_ui/classes/OralHistoryMods.py | 9 ++++++--- oh_staff_ui/templates/oh_staff_ui/release_notes.html | 8 +++++++- oh_staff_ui/tests.py | 6 ++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/charts/prod-ohstaff-values.yaml b/charts/prod-ohstaff-values.yaml index ff50880..75c43f3 100644 --- a/charts/prod-ohstaff-values.yaml +++ b/charts/prod-ohstaff-values.yaml @@ -6,7 +6,7 @@ replicaCount: 1 image: repository: uclalibrary/oral-history-staff-ui - tag: v1.1.10 + tag: v1.1.11 pullPolicy: Always nameOverride: "" diff --git a/oh_staff_ui/classes/OralHistoryMods.py b/oh_staff_ui/classes/OralHistoryMods.py index 2ffd5a8..6b7e54b 100644 --- a/oh_staff_ui/classes/OralHistoryMods.py +++ b/oh_staff_ui/classes/OralHistoryMods.py @@ -179,7 +179,8 @@ def _create_relateditem_audio(self, mi: MediaFile) -> MODSv34: for ts in MediaFile.objects.filter( item=pi, file_type__file_code="text_master_transcript" ): - if ts.file_url != "" and ts.file_url.endswith(".xml"): + # Add only for submasters, the public-access copy + if ts.file_url.endswith("submaster.xml"): # Due to legacy design the text_master_transcript can have 2 file types # associated with it, we only want to show xml (TEI), and ignore html files ri.locations.append(LocationOH(url=ts.file_url, usage="timed log")) @@ -208,7 +209,8 @@ def _populate_interview_content(self): for f in MediaFile.objects.filter( item=self._item, file_type__file_code__in=fc_to_label.keys() ).order_by("sequence"): - if f.file_url != "": + # Add only for submasters, the public-access copy + if "submaster" in f.file_url: label = fc_to_label[f.file_type.file_code] usage = "" @@ -219,7 +221,8 @@ def _populate_interview_content(self): label = f"{label} (TEI/P5 XML)" usage = "timed log" - # If our MediaFile is TEI/P5 XML, a usage attribute is populated and should be included + # If our MediaFile is TEI/P5 XML, a usage attribute is populated + # and should be included if usage: self.locations.append( LocationOH(url=f.file_url, label=label, usage=usage) diff --git a/oh_staff_ui/templates/oh_staff_ui/release_notes.html b/oh_staff_ui/templates/oh_staff_ui/release_notes.html index e1f9b04..a65ecf1 100644 --- a/oh_staff_ui/templates/oh_staff_ui/release_notes.html +++ b/oh_staff_ui/templates/oh_staff_ui/release_notes.html @@ -3,10 +3,16 @@ {% block content %}

Release Notes


+

1.1.11

+

June 12, 2024

+ +

1.1.10

June 6, 2024

1.1.9

diff --git a/oh_staff_ui/tests.py b/oh_staff_ui/tests.py index b9f8e1c..616f812 100644 --- a/oh_staff_ui/tests.py +++ b/oh_staff_ui/tests.py @@ -1543,6 +1543,12 @@ def test_sealed_audio_metadata_is_excluded(self): # That title should not be present, since that item has been Sealed. self.assertNotIn("Fake audio", related_titles) + def test_master_file_urls_are_excluded(self): + # Confirm that master file URLs, which are only used in the staff UI, + # are not included in the OAI feed. + ohmods = self.get_mods_from_interview_item() + self.assertFalse(b"/oh_masters/" in ohmods.serializeDocument()) + class FileMetadataMigrationTestCase(SimpleTestCase): # Test logic not already covered by OralHistoryFile tests.