mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 05:48:25 -04:00
Merge pull request #3879 from alphagov/add-government-channel
Add an option to set a service to the government channel for emergency alerts
This commit is contained in:
@@ -47,6 +47,12 @@
|
||||
box-shadow: 0 -3px 0 0 #F6D7D2;
|
||||
}
|
||||
|
||||
&--government {
|
||||
background: #942514;
|
||||
color: #F6D7D2;
|
||||
box-shadow: 0 -3px 0 0 #942514;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&-service-switch,
|
||||
|
||||
@@ -2316,6 +2316,8 @@ class ServiceBroadcastAccountTypeField(GovukRadiosField):
|
||||
# (service_mode, broadcast_channel, allowed_broadcast_provider)
|
||||
# to a value to be used in our form such as "live-severe-ee"
|
||||
def process_data(self, value):
|
||||
if not value or isinstance(value, str):
|
||||
return super().process_data(value)
|
||||
(live, broadcast_channel, allowed_broadcast_provider) = value
|
||||
account_type = None
|
||||
if broadcast_channel:
|
||||
@@ -2330,13 +2332,61 @@ class ServiceBroadcastAccountTypeField(GovukRadiosField):
|
||||
# broadcast_channel and provider_restriction to be used by the flask route to send to the
|
||||
# API
|
||||
def post_validate(self, form, validation_stopped):
|
||||
if not validation_stopped:
|
||||
if not validation_stopped and self.data:
|
||||
split_values = self.data.split("-")
|
||||
self.service_mode = split_values[0]
|
||||
self.broadcast_channel = split_values[1]
|
||||
self.provider_restriction = split_values[2] if len(split_values) == 3 else 'all'
|
||||
|
||||
|
||||
class OptionalServiceBroadcastAccountTypeField(ServiceBroadcastAccountTypeField):
|
||||
def pre_validate(self, form):
|
||||
if self.data is None:
|
||||
return
|
||||
super().pre_validate(form)
|
||||
|
||||
|
||||
class ServiceBroadcastChannelForm(StripWhitespaceForm):
|
||||
channel = ServiceBroadcastAccountTypeField(
|
||||
'Emergency alerts settings',
|
||||
thing='mode or channel',
|
||||
choices=[
|
||||
("training-test", "Training mode"),
|
||||
("live-test", "Test channel"),
|
||||
("live-severe", "Live channel"),
|
||||
("live-government", "Government channel"),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class ServiceBroadcastNetworkForm(StripWhitespaceForm):
|
||||
|
||||
network_variant = ServiceBroadcastAccountTypeField(
|
||||
'Choose a mobile network',
|
||||
thing='a mobile network',
|
||||
choices=[
|
||||
('live-test', 'All networks'),
|
||||
('', 'A single network'),
|
||||
]
|
||||
)
|
||||
network = OptionalServiceBroadcastAccountTypeField(
|
||||
'Choose a mobile network',
|
||||
thing='a mobile network',
|
||||
choices=[
|
||||
('live-test-ee', 'EE'),
|
||||
('live-test-o2', 'O2'),
|
||||
('live-test-vodafone', 'Vodafone'),
|
||||
('live-test-three', 'Three'),
|
||||
],
|
||||
)
|
||||
|
||||
def validate_network(self, field):
|
||||
if not self.network_variant.data and not field.data:
|
||||
raise ValidationError('Select a mobile network')
|
||||
if self.network_variant.data == 'all':
|
||||
field.data = ''
|
||||
|
||||
|
||||
class ServiceBroadcastAccountTypeForm(StripWhitespaceForm):
|
||||
account_type = ServiceBroadcastAccountTypeField(
|
||||
'Change cell broadcast service type',
|
||||
@@ -2349,6 +2399,7 @@ class ServiceBroadcastAccountTypeForm(StripWhitespaceForm):
|
||||
("live-test-vodafone", "Test channel (Vodafone)"),
|
||||
("live-test", "Test channel (all networks)"),
|
||||
("live-severe", "Live (all networks)"),
|
||||
("live-government", "Government channel (all networks)"),
|
||||
],
|
||||
validators=[DataRequired()]
|
||||
)
|
||||
|
||||
@@ -46,6 +46,8 @@ from app.main.forms import (
|
||||
RenameServiceForm,
|
||||
SearchByNameForm,
|
||||
ServiceBroadcastAccountTypeForm,
|
||||
ServiceBroadcastChannelForm,
|
||||
ServiceBroadcastNetworkForm,
|
||||
ServiceContactDetailsForm,
|
||||
ServiceDataRetentionEditForm,
|
||||
ServiceDataRetentionForm,
|
||||
@@ -318,15 +320,79 @@ def service_set_permission(service_id, permission):
|
||||
|
||||
@main.route("/services/<uuid:service_id>/service-settings/broadcasts", methods=["GET", "POST"])
|
||||
@user_is_platform_admin
|
||||
def service_set_broadcast_account_type(service_id):
|
||||
form = ServiceBroadcastAccountTypeForm(
|
||||
account_type=(
|
||||
def service_set_broadcast_channel(service_id):
|
||||
form = ServiceBroadcastChannelForm(
|
||||
channel=(
|
||||
current_service.live,
|
||||
current_service.broadcast_channel,
|
||||
current_service.allowed_broadcast_provider
|
||||
'all',
|
||||
)
|
||||
)
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.channel.data == 'live-test':
|
||||
return redirect(url_for(
|
||||
'.service_set_broadcast_network',
|
||||
service_id=current_service.id,
|
||||
))
|
||||
return redirect(url_for(
|
||||
'.service_confirm_broadcast_account_type',
|
||||
service_id=current_service.id,
|
||||
account_type=form.channel.data,
|
||||
))
|
||||
|
||||
return render_template(
|
||||
'views/service-settings/service-set-broadcast-channel.html',
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/service-settings/broadcasts/network", methods=["GET", "POST"])
|
||||
@user_is_platform_admin
|
||||
def service_set_broadcast_network(service_id):
|
||||
if current_service.allowed_broadcast_provider == 'all':
|
||||
form = ServiceBroadcastNetworkForm(
|
||||
network_variant=(
|
||||
current_service.live,
|
||||
current_service.broadcast_channel,
|
||||
current_service.allowed_broadcast_provider,
|
||||
),
|
||||
)
|
||||
else:
|
||||
form = ServiceBroadcastNetworkForm(
|
||||
network_variant='',
|
||||
network=(
|
||||
current_service.live,
|
||||
current_service.broadcast_channel,
|
||||
current_service.allowed_broadcast_provider
|
||||
)
|
||||
)
|
||||
|
||||
if form.validate_on_submit():
|
||||
return redirect(url_for(
|
||||
'.service_confirm_broadcast_account_type',
|
||||
service_id=current_service.id,
|
||||
account_type=form.network_variant.data or form.network.data,
|
||||
))
|
||||
|
||||
return render_template(
|
||||
'views/service-settings/service-set-broadcast-network.html',
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/service-settings/broadcasts/<account_type>",
|
||||
methods=["GET", "POST"]
|
||||
)
|
||||
@user_is_platform_admin
|
||||
def service_confirm_broadcast_account_type(service_id, account_type):
|
||||
form = ServiceBroadcastAccountTypeForm(account_type=account_type)
|
||||
form.validate()
|
||||
|
||||
if form.account_type.errors:
|
||||
abort(404)
|
||||
|
||||
if form.validate_on_submit():
|
||||
service_api_client.set_service_broadcast_settings(
|
||||
current_service.id,
|
||||
@@ -341,11 +407,10 @@ def service_set_broadcast_account_type(service_id):
|
||||
broadcast_channel=form.account_type.broadcast_channel,
|
||||
provider_restriction=form.account_type.provider_restriction,
|
||||
)
|
||||
|
||||
return redirect(url_for(".service_settings", service_id=service_id))
|
||||
|
||||
return render_template(
|
||||
'views/service-settings/service-set-broadcast-account-type.html',
|
||||
'views/service-settings/service-confirm-broadcast-account-type.html',
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@@ -243,7 +243,9 @@ class MainNavigation(Navigation):
|
||||
'service_set_auth_type',
|
||||
'service_set_channel',
|
||||
'send_files_by_email_contact_details',
|
||||
'service_set_broadcast_account_type',
|
||||
'service_confirm_broadcast_account_type',
|
||||
'service_set_broadcast_channel',
|
||||
'service_set_broadcast_network',
|
||||
'service_set_email_branding',
|
||||
'service_set_inbound_number',
|
||||
'service_set_inbound_sms',
|
||||
|
||||
@@ -429,20 +429,21 @@
|
||||
{% endfor %}
|
||||
|
||||
{% call row() %}
|
||||
{{ text_field('Send cell broadcasts')}}
|
||||
{{ text_field('Emergency alerts')}}
|
||||
{% call field(wrap=True) %}
|
||||
{% if not current_service.broadcast_channel %}
|
||||
Off
|
||||
{% else %}
|
||||
{% if current_service.live and current_service.broadcast_channel == "government" %}Government{% endif %}
|
||||
{% 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 != "all" %}({{ 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 != "all" %}({{ current_service.allowed_broadcast_provider|format_mobile_network }}){% else %}(all networks){% endif %}{%endif%}
|
||||
{% if not current_service.live%}Training {% endif%}
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.service_set_broadcast_account_type', service_id=current_service.id),
|
||||
suffix='your settings for Send cell broadcasts'
|
||||
url_for('.service_set_broadcast_channel', service_id=current_service.id),
|
||||
suffix='your settings for emergency alerts'
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/page-header.html" import page_header %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
{% from "components/form.html" import form_wrapper %}
|
||||
|
||||
{% block service_page_title %}
|
||||
Confirm emergency alert settings
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-grid-column-five-sixths">
|
||||
{{ page_header(
|
||||
'Confirm emergency alert settings',
|
||||
back_link=url_for('.service_set_broadcast_channel', service_id=current_service.id)
|
||||
) }}
|
||||
{% if form.account_type.service_mode == 'training' %}
|
||||
<p class="govuk-body">
|
||||
<span class="navigation-service-type navigation-service-type--training govuk-!-margin-left-0">Training</span>
|
||||
</p>
|
||||
<p class="govuk-body">
|
||||
No phones will receive alerts sent from this service.
|
||||
</p>
|
||||
{% else %}
|
||||
<p class="govuk-body">
|
||||
{% if form.account_type.broadcast_channel == 'severe' %}
|
||||
<span class="navigation-service-type navigation-service-type--live govuk-!-margin-left-0">Live
|
||||
{% elif form.account_type.broadcast_channel == 'government' %}
|
||||
<span class="navigation-service-type navigation-service-type--government govuk-!-margin-left-0">Government
|
||||
{% else %}
|
||||
<span class="navigation-service-type navigation-service-type--live govuk-!-margin-left-0">{{ form.account_type.broadcast_channel|title }}
|
||||
{% endif %}
|
||||
{% if form.account_type.provider_restriction != 'all' %}
|
||||
({{ form.account_type.provider_restriction|format_mobile_network }})
|
||||
{% endif %}
|
||||
{% if form.account_type.broadcast_channel == 'test' and form.account_type.provider_restriction == 'all'%}
|
||||
(all networks)
|
||||
{% endif %}
|
||||
</span>
|
||||
</p>
|
||||
<p class="govuk-body">
|
||||
Members of the public
|
||||
{% if form.account_type.broadcast_channel == 'test' %}
|
||||
who have switched on the test channel on their phones
|
||||
{% endif %}
|
||||
will receive alerts sent from this service
|
||||
{%- if form.account_type.broadcast_channel == 'government' -%}
|
||||
, even if they’ve opted out
|
||||
{%- endif %}.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% call form_wrapper() %}
|
||||
{{ page_footer('Confirm') }}
|
||||
{% endcall %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -6,7 +6,7 @@
|
||||
{% block service_page_title %}
|
||||
Send cell broadcasts
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<div class="govuk-grid-row">
|
||||
@@ -24,7 +24,7 @@
|
||||
}
|
||||
}
|
||||
}) }}
|
||||
{{ page_footer('Save') }}
|
||||
{{ page_footer('Continue') }}
|
||||
{% endcall %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
{% from "components/form.html" import form_wrapper %}
|
||||
{% from "components/back-link/macro.njk" import govukBackLink %}
|
||||
|
||||
{% block service_page_title %}
|
||||
Emergency alerts settings
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-grid-column-five-sixths">
|
||||
{{ govukBackLink({
|
||||
"text": "Back",
|
||||
"href": url_for('.service_settings', service_id=current_service.id)
|
||||
}) }}
|
||||
{% call form_wrapper() %}
|
||||
{{ form.channel(param_extensions={
|
||||
'fieldset': {
|
||||
'legend': {
|
||||
'isPageHeading': True,
|
||||
'classes': 'govuk-fieldset__legend--l'
|
||||
}
|
||||
}
|
||||
}) }}
|
||||
{{ page_footer('Continue') }}
|
||||
{% endcall %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,37 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/page-header.html" import page_header %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
{% from "components/form.html" import form_wrapper %}
|
||||
{% from "components/radios.html" import radio, conditional_radio_panel %}
|
||||
{% from "components/select-input.html" import select_wrapper %}
|
||||
{% from "components/back-link/macro.njk" import govukBackLink %}
|
||||
|
||||
{% block service_page_title %}
|
||||
Choose a mobile network
|
||||
{% endblock %}
|
||||
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-grid-column-five-sixths">
|
||||
{{ page_header(
|
||||
'Choose a mobile network',
|
||||
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) }}
|
||||
{% endfor %}
|
||||
{% endcall %}
|
||||
{% call conditional_radio_panel('single-network') %}
|
||||
{{ form.network(
|
||||
param_extensions={'fieldset': {'legend': {'classes': 'govuk-visually-hidden'}}}
|
||||
) }}
|
||||
{% endcall %}
|
||||
{{ page_footer('Continue') }}
|
||||
{% endcall %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -22,11 +22,17 @@
|
||||
{% elif current_service.has_permission('broadcast') %}
|
||||
{% if current_service.trial_mode %}
|
||||
<span class="navigation-service-type navigation-service-type--training">Training
|
||||
{% else %}
|
||||
{% elif current_service.broadcast_channel == 'severe' %}
|
||||
<span class="navigation-service-type navigation-service-type--live">Live
|
||||
{% endif %}
|
||||
{% if current_service.allowed_broadcast_provider != "all" %}
|
||||
({{ current_service.allowed_broadcast_provider }})
|
||||
{% elif current_service.broadcast_channel == 'test' %}
|
||||
<span class="navigation-service-type navigation-service-type--live">{{ current_service.broadcast_channel|title }}
|
||||
{% if current_service.allowed_broadcast_provider == "all" %}
|
||||
(all networks)
|
||||
{% else %}
|
||||
({{ current_service.allowed_broadcast_provider }})
|
||||
{% endif %}
|
||||
{% elif current_service.broadcast_channel == 'government' %}
|
||||
<span class="navigation-service-type navigation-service-type--government">Government
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user