From 3485475270d23e1c3a576e87eb4cb60dec89c71b Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Mon, 10 May 2021 14:35:18 +0100 Subject: [PATCH] Allow provider_restriction to be None or "all" Until all the data is updated to always be "all", we have to handle the case of provider_restriction being set to None or "all" (which mean the same thing). The code can be tidied up once the broadcast provider_restriction is never None. --- app/main/forms.py | 2 +- app/notify_client/service_api_client.py | 2 +- app/templates/views/service-settings.html | 2 +- app/templates/withnav_template.html | 2 +- tests/app/main/views/test_broadcast.py | 14 ++++++++++++++ tests/app/main/views/test_service_settings.py | 19 +++++++++++++++++++ 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index 6f16fd098..ac240991f 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -2321,7 +2321,7 @@ class ServiceBroadcastAccountTypeField(GovukRadiosField): if broadcast_channel: account_type = "live" if live else "training" account_type += f"-{broadcast_channel}" - if allowed_broadcast_provider: + if allowed_broadcast_provider and allowed_broadcast_provider != 'all': account_type += f"-{allowed_broadcast_provider}" self.data = account_type diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index 034e940f3..1c2f09a93 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -623,7 +623,7 @@ class ServiceAPIClient(NotifyAdminAPIClient): """ service_mode is one of "training" or "live" broadcast channel is one of "test" or "severe" - provider_restriction is one of None, "three", "o2", "vodafone", "ee" + provider_restriction is one of "all", "three", "o2", "vodafone", "ee" """ data = { "service_mode": service_mode, diff --git a/app/templates/views/service-settings.html b/app/templates/views/service-settings.html index 1c7f9443b..d27da9c94 100644 --- a/app/templates/views/service-settings.html +++ b/app/templates/views/service-settings.html @@ -435,7 +435,7 @@ Off {% else %} {% if current_service.live and current_service.broadcast_channel == "severe" %}Live{% endif %} - {% if current_service.live and current_service.broadcast_channel == "test" %}Test {% if current_service.allowed_broadcast_provider %}({{ current_service.allowed_broadcast_provider|format_mobile_network }}){% else %}(All networks){% endif %}{%endif%} + {% if current_service.live and current_service.broadcast_channel == "test" %}Test {% if current_service.allowed_broadcast_provider and current_service.allowed_broadcast_provider != "all" %}({{ current_service.allowed_broadcast_provider|format_mobile_network }}){% else %}(All networks){% endif %}{%endif%} {% if not current_service.live%}Training {% endif%} {% endif %} {% endcall %} diff --git a/app/templates/withnav_template.html b/app/templates/withnav_template.html index 356bd1ccf..67530f90d 100644 --- a/app/templates/withnav_template.html +++ b/app/templates/withnav_template.html @@ -25,7 +25,7 @@ {% else %} Live {% endif %} - {% if current_service.allowed_broadcast_provider %} + {% if current_service.allowed_broadcast_provider and current_service.allowed_broadcast_provider != "all" %} ({{ current_service.allowed_broadcast_provider }}) {% endif %} diff --git a/tests/app/main/views/test_broadcast.py b/tests/app/main/views/test_broadcast.py index 406619e4d..1c4ef92bc 100644 --- a/tests/app/main/views/test_broadcast.py +++ b/tests/app/main/views/test_broadcast.py @@ -301,6 +301,20 @@ def test_broadcast_tour_page_4_shows_service_name( 'service one Live Switch service', 'Live', ), + ( + True, + "all", + '.navigation-service-type.navigation-service-type--training', + 'service one Training Switch service', + 'Training', + ), + ( + False, + "all", + '.navigation-service-type.navigation-service-type--live', + 'service one Live Switch service', + 'Live', + ), ( True, diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 659aab305..86a4c6161 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -199,12 +199,17 @@ def test_platform_admin_sees_only_relevant_settings_for_broadcast_service( 'has_broadcast_permission,service_mode,broadcast_channel,allowed_broadcast_provider,expected_text', [ (False, "training", None, None, "Off"), + (False, "training", None, "all", "Off"), (False, "live", None, None, "Off"), + (False, "live", None, "all", "Off"), (True, "training", "test", None, "Training"), + (True, "training", "test", "all", "Training"), (True, "live", "test", "ee", "Test (EE)"), (True, "live", "test", "three", "Test (Three)"), (True, "live", "test", None, "Test (All networks)"), + (True, "live", "test", "all", "Test (All networks)"), (True, "live", "severe", None, "Live"), + (True, "live", "severe", "all", "Live"), ] ) def test_platform_admin_sees_correct_description_of_broadcast_service_setting( @@ -5470,6 +5475,13 @@ def test_get_service_set_broadcast_account_type_has_no_radio_selected_for_non_br "Training mode", "training-test", ), + ( + "training", + "test", + "all", + "Training mode", + "training-test", + ), ( "live", "test", @@ -5484,6 +5496,13 @@ def test_get_service_set_broadcast_account_type_has_no_radio_selected_for_non_br "Live (all networks)", "live-severe", ), + ( + "live", + "severe", + "all", + "Live (all networks)", + "live-severe", + ), ] ) def test_get_service_set_broadcast_account_type_has_radio_selected_for_broadcast_service(