mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 09:19:48 -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:
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user