From 6498ad8726688ed5c599fd40004c7427fd50aee6 Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Tue, 6 Feb 2024 16:05:02 +0100 Subject: [PATCH] remove station name from subjects CPCN-604 --- server/cp/signals.py | 3 ++- server/tests/test_signals.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/server/cp/signals.py b/server/cp/signals.py index 6b917f5..e3d111c 100644 --- a/server/cp/signals.py +++ b/server/cp/signals.py @@ -106,7 +106,8 @@ def handle_transcripts(item): media_type["name"] = get_media_type_name(media_type["code"], item["language"]) if media_source: - item["source"] = media_source["name"] + item["source"] = media_source.get("name") or media_source.get("code") + item["subject"] = [s for s in item["subject"] if s.get("scheme") != media_source_scheme] if media_type and media_type["code"] in ("tvstation", "radionstation"): # it might be already populated based on previous segment diff --git a/server/tests/test_signals.py b/server/tests/test_signals.py index e241a70..980adf3 100644 --- a/server/tests/test_signals.py +++ b/server/tests/test_signals.py @@ -217,4 +217,5 @@ def test_handle_transcripts(app): transcript_item["language"] = "fr-CA" signals.on_publish_item(None, transcript_item) + assert 1 == len(transcript_item["subject"]) assert "Station de télé" == transcript_item["subject"][0]["name"]