diff --git a/app/main/forms.py b/app/main/forms.py index 7f784d0aa..09be3f5b9 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -2409,11 +2409,6 @@ class ServiceBroadcastNetworkForm(StripWhitespaceForm): super().__init__(*args, **kwargs) self.broadcast_channel = broadcast_channel - self.network_variant.choices = [ - (f'live-{broadcast_channel}-all', 'All networks'), - ('', 'A single network'), - ] - self.network.choices = [ (f'live-{broadcast_channel}-ee', 'EE'), (f'live-{broadcast_channel}-o2', 'O2'), @@ -2421,9 +2416,12 @@ class ServiceBroadcastNetworkForm(StripWhitespaceForm): (f'live-{broadcast_channel}-three', 'Three'), ] - network_variant = ServiceBroadcastAccountTypeField( + all_networks = OnOffField( 'Choose a mobile network', - thing='a mobile network', + choices=( + (True, 'All networks'), + (False, 'A single network') + ), ) network = OptionalServiceBroadcastAccountTypeField( 'Choose a mobile network', @@ -2432,7 +2430,7 @@ class ServiceBroadcastNetworkForm(StripWhitespaceForm): @property def account_type(self): - if self.network_variant.data == f'live-{self.broadcast_channel}-all': + if self.all_networks.data: provider = 'all' else: provider = self.network.provider_restriction @@ -2440,7 +2438,7 @@ class ServiceBroadcastNetworkForm(StripWhitespaceForm): return f'live-{self.broadcast_channel}-{provider}' def validate_network(self, field): - if not self.network_variant.data and not field.data: + if not self.all_networks.data and not field.data: raise ValidationError('Select a mobile network') diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index f9ef5cef2..681052047 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -353,23 +353,21 @@ def service_set_broadcast_channel(service_id): def service_set_broadcast_network(service_id, broadcast_channel): # only populate old settings when the channel is unchanged if current_service.broadcast_channel == broadcast_channel: - if current_service.allowed_broadcast_provider == 'all': + provider = current_service.allowed_broadcast_provider + + if provider == 'all': form = ServiceBroadcastNetworkForm( broadcast_channel=broadcast_channel, - network_variant=( - current_service.live, - current_service.broadcast_channel, - current_service.allowed_broadcast_provider, - ), + all_networks=True, ) else: form = ServiceBroadcastNetworkForm( broadcast_channel=broadcast_channel, - network_variant='', + all_networks=False, network=( current_service.live, current_service.broadcast_channel, - current_service.allowed_broadcast_provider + provider, ) ) else: diff --git a/app/templates/views/service-settings/service-set-broadcast-network.html b/app/templates/views/service-settings/service-set-broadcast-network.html index a32f24819..72948e639 100644 --- a/app/templates/views/service-settings/service-set-broadcast-network.html +++ b/app/templates/views/service-settings/service-set-broadcast-network.html @@ -19,9 +19,9 @@ back_link=url_for('.service_set_broadcast_channel', service_id=current_service.id) ) }} {% call form_wrapper() %} - {% call select_wrapper(form.network_variant, hide_legend=True) %} - {% for option in form.network_variant %} - {{ radio(option, data_target='single-network' if option.data == "" else None) }} + {% call select_wrapper(form.all_networks, hide_legend=True) %} + {% for option in form.all_networks %} + {{ radio(option, data_target='single-network' if option.data == False else None) }} {% endfor %} {% endcall %} {% call conditional_radio_panel('single-network') %} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 44f826d82..82d6d13b4 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -5649,18 +5649,12 @@ def test_service_set_broadcast_channel_redirects( @pytest.mark.parametrize( 'service_mode,broadcast_channel,allowed_broadcast_provider,expected_selected', [ - ( - "training", - "test", - "all", - [], - ), ( "live", "severe", "all", [ - ("All networks", "live-severe-all"), + ("All networks", "True"), ], ), ( @@ -5668,7 +5662,7 @@ def test_service_set_broadcast_channel_redirects( "government", "all", [ - ("All networks", "live-government-all"), + ("All networks", "True"), ], ), ( @@ -5676,7 +5670,7 @@ def test_service_set_broadcast_channel_redirects( "test", "all", [ - ("All networks", "live-test-all"), + ("All networks", "True"), ], ), ( @@ -5684,7 +5678,7 @@ def test_service_set_broadcast_channel_redirects( "test", "ee", [ - ("A single network", ""), + ("A single network", "False"), ("EE", "live-test-ee"), ], ), @@ -5693,7 +5687,7 @@ def test_service_set_broadcast_channel_redirects( "test", "o2", [ - ("A single network", ""), + ("A single network", "False"), ("O2", "live-test-o2"), ], ), @@ -5702,7 +5696,7 @@ def test_service_set_broadcast_channel_redirects( "test", "three", [ - ("A single network", ""), + ("A single network", "False"), ("Three", "live-test-three"), ], ), @@ -5711,7 +5705,7 @@ def test_service_set_broadcast_channel_redirects( "test", "vodafone", [ - ("A single network", ""), + ("A single network", "False"), ("Vodafone", "live-test-vodafone"), ], ), @@ -5720,7 +5714,7 @@ def test_service_set_broadcast_channel_redirects( "severe", "vodafone", [ - ("A single network", ""), + ("A single network", "False"), ("Vodafone", "live-severe-vodafone"), ], ), @@ -5729,7 +5723,7 @@ def test_service_set_broadcast_channel_redirects( "government", "vodafone", [ - ("A single network", ""), + ("A single network", "False"), ("Vodafone", "live-government-vodafone"), ], ), @@ -5793,9 +5787,9 @@ def test_service_set_broadcast_network( expected_result = f'live-{broadcast_channel}-{provider}' if choice_type == 'network_variant': - data = {'network_variant': expected_result} + data = {'all_networks': True} else: - data = {'network_variant': '', 'network': expected_result} + data = {'all_networks': False, 'network': expected_result} client_request.login(platform_admin_user) client_request.post( @@ -5817,7 +5811,7 @@ def test_service_set_broadcast_network( 'data', ( {}, - {'network_variant': ''}, # Missing choice of MNO + {'all_networks': ''}, # Missing choice of MNO ), ) @pytest.mark.parametrize('broadcast_channel', ['government', 'severe', 'test'])