mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-26 09:13:58 -04:00
Merge pull request #3519 from alphagov/broadcast-settings
Remove emails, text messages and letter permissions from broadcast services
This commit is contained in:
@@ -305,6 +305,35 @@ def service_set_permission(service_id, permission):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/service-settings/permissions/broadcast", methods=["GET", "POST"])
|
||||
@user_is_platform_admin
|
||||
def service_set_broadcast_permission(service_id):
|
||||
|
||||
title = PLATFORM_ADMIN_SERVICE_PERMISSIONS['broadcast']['title']
|
||||
form = ServiceOnOffSettingForm(
|
||||
name=title,
|
||||
enabled=current_service.has_permission('broadcast')
|
||||
)
|
||||
|
||||
if form.validate_on_submit():
|
||||
|
||||
if form.enabled.data:
|
||||
current_service.force_permission('broadcast', on=True)
|
||||
current_service.force_permission('email', on=False)
|
||||
current_service.force_permission('sms', on=False)
|
||||
current_service.force_permission('letter', on=False)
|
||||
else:
|
||||
current_service.force_permission('broadcast', on=False)
|
||||
|
||||
return redirect(url_for(".service_settings", service_id=service_id))
|
||||
|
||||
return render_template(
|
||||
'views/service-settings/set-service-setting.html',
|
||||
title=title,
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/service-settings/archive", methods=['GET', 'POST'])
|
||||
@user_has_permissions('manage_service')
|
||||
def archive_service(service_id):
|
||||
@@ -667,6 +696,9 @@ def service_set_channel(service_id, channel):
|
||||
if channel not in {'email', 'sms', 'letter'}:
|
||||
abort(404)
|
||||
|
||||
if current_service.has_permission('broadcast'):
|
||||
abort(403)
|
||||
|
||||
form = ServiceSwitchChannelForm(
|
||||
channel=channel,
|
||||
enabled=current_service.has_permission(channel)
|
||||
|
||||
@@ -307,6 +307,7 @@ class HeaderNavigation(Navigation):
|
||||
'service_switch_count_as_live',
|
||||
'service_switch_live',
|
||||
'service_set_permission',
|
||||
'service_set_broadcast_permission',
|
||||
'service_verify_reply_to_address',
|
||||
'service_verify_reply_to_address_updates',
|
||||
'services_or_dashboard',
|
||||
@@ -635,6 +636,7 @@ class MainNavigation(Navigation):
|
||||
'service_switch_count_as_live',
|
||||
'service_switch_live',
|
||||
'service_set_permission',
|
||||
'service_set_broadcast_permission',
|
||||
'services_or_dashboard',
|
||||
'show_accounts_or_dashboard',
|
||||
'sign_in',
|
||||
@@ -933,6 +935,7 @@ class CaseworkNavigation(Navigation):
|
||||
'service_switch_count_as_live',
|
||||
'service_switch_live',
|
||||
'service_set_permission',
|
||||
'service_set_broadcast_permission',
|
||||
'service_verify_reply_to_address',
|
||||
'service_verify_reply_to_address_updates',
|
||||
'services_or_dashboard',
|
||||
@@ -1237,6 +1240,7 @@ class OrgNavigation(Navigation):
|
||||
'service_switch_count_as_live',
|
||||
'service_switch_live',
|
||||
'service_set_permission',
|
||||
'service_set_broadcast_permission',
|
||||
'service_verify_reply_to_address',
|
||||
'service_verify_reply_to_address_updates',
|
||||
'services_or_dashboard',
|
||||
|
||||
@@ -47,215 +47,220 @@
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
|
||||
{% call mapping_table(
|
||||
caption='Email settings',
|
||||
field_headings=['Label', 'Value', 'Action'],
|
||||
field_headings_visible=False,
|
||||
caption_visible=True
|
||||
) %}
|
||||
{% if not current_service.has_permission('broadcast') %}
|
||||
|
||||
{% call mapping_table(
|
||||
caption='Email settings',
|
||||
field_headings=['Label', 'Value', 'Action'],
|
||||
field_headings_visible=False,
|
||||
caption_visible=True
|
||||
) %}
|
||||
|
||||
{% call row() %}
|
||||
{{ text_field('Send emails') }}
|
||||
{{ boolean_field('email' in current_service.permissions) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for(
|
||||
'.service_set_channel',
|
||||
channel='email',
|
||||
service_id=current_service.id
|
||||
),
|
||||
permissions=['manage_service']
|
||||
)}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='email') %}
|
||||
{{ text_field('Reply-to email addresses') }}
|
||||
{% call field(status='default' if current_service.count_email_reply_to_addresses == 0 else '') %}
|
||||
{{ current_service.default_email_reply_to_address or 'Not set' }}
|
||||
{% if current_service.count_email_reply_to_addresses > 1 %}
|
||||
<div class="hint">
|
||||
{{ '…and %d more' | format(current_service.count_email_reply_to_addresses - 1) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{{ edit_field(
|
||||
'Manage',
|
||||
url_for('.service_email_reply_to',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service','manage_api_keys']
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='email') %}
|
||||
{{ text_field('Email branding') }}
|
||||
{{ text_field(current_service.email_branding_name) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.branding_request', service_id=current_service.id, branding_type="email"),
|
||||
permissions=['manage_service'],
|
||||
)}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='email') %}
|
||||
{{ text_field('Send files by email') }}
|
||||
{{ text_field(current_service.contact_link if current_service.contact_link else "Not set up", truncate=true) }}
|
||||
{{ edit_field(
|
||||
'Manage',
|
||||
url_for('.send_files_by_email_contact_details', service_id=current_service.id),
|
||||
permissions=['manage_service'],
|
||||
)}}
|
||||
{% endcall %}
|
||||
|
||||
{% call row() %}
|
||||
{{ text_field('Send emails') }}
|
||||
{{ boolean_field('email' in current_service.permissions) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for(
|
||||
'.service_set_channel',
|
||||
channel='email',
|
||||
service_id=current_service.id
|
||||
),
|
||||
permissions=['manage_service']
|
||||
)}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='email') %}
|
||||
{{ text_field('Reply-to email addresses') }}
|
||||
{% call field(status='default' if current_service.count_email_reply_to_addresses == 0 else '') %}
|
||||
{{ current_service.default_email_reply_to_address or 'Not set' }}
|
||||
{% if current_service.count_email_reply_to_addresses > 1 %}
|
||||
<div class="hint">
|
||||
{{ '…and %d more' | format(current_service.count_email_reply_to_addresses - 1) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% call mapping_table(
|
||||
caption='Text message settings',
|
||||
field_headings=['Label', 'Value', 'Action'],
|
||||
field_headings_visible=False,
|
||||
caption_visible=True
|
||||
) %}
|
||||
|
||||
{% call row() %}
|
||||
{{ text_field('Send text messages') }}
|
||||
{{ boolean_field('sms' in current_service.permissions) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for(
|
||||
'.service_set_channel',
|
||||
service_id=current_service.id,
|
||||
channel='sms'
|
||||
),
|
||||
permissions=['manage_service']
|
||||
)}}
|
||||
{% endcall %}
|
||||
{{ edit_field(
|
||||
'Manage',
|
||||
url_for('.service_email_reply_to',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service','manage_api_keys']
|
||||
|
||||
{% call settings_row(if_has_permission='sms') %}
|
||||
{{ text_field('Text message senders') }}
|
||||
{% call field(status='default' if current_service.default_sms_sender == "None" else '') %}
|
||||
{{ current_service.default_sms_sender | nl2br if current_service.default_sms_sender else 'None'}}
|
||||
{% if current_service.count_sms_senders > 1 %}
|
||||
<div class="hint">
|
||||
{{ '…and %d more' | format(current_service.count_sms_senders - 1) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{{ edit_field(
|
||||
'Manage',
|
||||
url_for('.service_sms_senders',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service','manage_api_keys']
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='email') %}
|
||||
{{ text_field('Email branding') }}
|
||||
{{ text_field(current_service.email_branding_name) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.branding_request', service_id=current_service.id, branding_type="email"),
|
||||
permissions=['manage_service'],
|
||||
)}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='email') %}
|
||||
{{ text_field('Send files by email') }}
|
||||
{{ text_field(current_service.contact_link if current_service.contact_link else "Not set up", truncate=true) }}
|
||||
{{ edit_field(
|
||||
'Manage',
|
||||
url_for('.send_files_by_email_contact_details', service_id=current_service.id),
|
||||
permissions=['manage_service'],
|
||||
)}}
|
||||
{% endcall %}
|
||||
|
||||
{% endcall %}
|
||||
|
||||
{% call mapping_table(
|
||||
caption='Text message settings',
|
||||
field_headings=['Label', 'Value', 'Action'],
|
||||
field_headings_visible=False,
|
||||
caption_visible=True
|
||||
) %}
|
||||
|
||||
{% call row() %}
|
||||
{{ text_field('Send text messages') }}
|
||||
{{ boolean_field('sms' in current_service.permissions) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for(
|
||||
'.service_set_channel',
|
||||
service_id=current_service.id,
|
||||
channel='sms'
|
||||
),
|
||||
permissions=['manage_service']
|
||||
)}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='sms') %}
|
||||
{{ text_field('Text message senders') }}
|
||||
{% call field(status='default' if current_service.default_sms_sender == "None" else '') %}
|
||||
{{ current_service.default_sms_sender | nl2br if current_service.default_sms_sender else 'None'}}
|
||||
{% if current_service.count_sms_senders > 1 %}
|
||||
<div class="hint">
|
||||
{{ '…and %d more' | format(current_service.count_sms_senders - 1) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
}}
|
||||
{% endcall %}
|
||||
{{ edit_field(
|
||||
'Manage',
|
||||
url_for('.service_sms_senders',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service','manage_api_keys']
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='sms') %}
|
||||
{{ text_field('Start text messages with service name') }}
|
||||
{{ boolean_field(current_service.prefix_sms) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.service_set_sms_prefix',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service']
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='sms') %}
|
||||
{{ text_field('Send international text messages') }}
|
||||
{{ boolean_field('international_sms' in current_service.permissions) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.service_set_international_sms',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service']
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='sms') %}
|
||||
{{ text_field('Receive text messages') }}
|
||||
{{ boolean_field('inbound_sms' in current_service.permissions) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.service_set_inbound_sms',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service']
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
|
||||
{% endcall %}
|
||||
|
||||
{% call mapping_table(
|
||||
caption='Letter settings',
|
||||
field_headings=['Label', 'Value', 'Action'],
|
||||
field_headings_visible=False,
|
||||
caption_visible=True
|
||||
) %}
|
||||
|
||||
{% call row() %}
|
||||
{{ text_field('Send letters') }}
|
||||
{{ boolean_field('letter' in current_service.permissions) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for(
|
||||
'.service_set_channel',
|
||||
channel='letter',
|
||||
service_id=current_service.id
|
||||
),
|
||||
permissions=['manage_service']
|
||||
)}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='letter') %}
|
||||
{{ text_field('Sender addresses') }}
|
||||
{% call field(status='' if current_service.count_letter_contact_details else 'default') %}
|
||||
{% if current_service.default_letter_contact_block %}
|
||||
{{ current_service.default_letter_contact_block_html }}
|
||||
{% elif current_service.count_letter_contact_details %}
|
||||
Blank
|
||||
{% else %}
|
||||
Not set
|
||||
{% endif %}
|
||||
{% if current_service.count_letter_contact_details > 1 %}
|
||||
<div class="hint">
|
||||
{{ '…and %d more' | format(current_service.count_letter_contact_details - 1) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% call settings_row(if_has_permission='sms') %}
|
||||
{{ text_field('Start text messages with service name') }}
|
||||
{{ boolean_field(current_service.prefix_sms) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.service_set_sms_prefix',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service']
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
{{ edit_field(
|
||||
'Manage',
|
||||
url_for('.service_letter_contact_details',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service','manage_api_keys']
|
||||
)
|
||||
}}
|
||||
|
||||
{% call settings_row(if_has_permission='sms') %}
|
||||
{{ text_field('Send international text messages') }}
|
||||
{{ boolean_field('international_sms' in current_service.permissions) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.service_set_international_sms',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service']
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='sms') %}
|
||||
{{ text_field('Receive text messages') }}
|
||||
{{ boolean_field('inbound_sms' in current_service.permissions) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.service_set_inbound_sms',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service']
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='letter') %}
|
||||
{{ text_field('Letter branding') }}
|
||||
{{ optional_text_field(current_service.letter_branding.name) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.branding_request', service_id=current_service.id, branding_type="letter"),
|
||||
permissions=['manage_service']
|
||||
)}}
|
||||
{% endcall %}
|
||||
{% call mapping_table(
|
||||
caption='Letter settings',
|
||||
field_headings=['Label', 'Value', 'Action'],
|
||||
field_headings_visible=False,
|
||||
caption_visible=True
|
||||
) %}
|
||||
|
||||
{% endcall %}
|
||||
{% call row() %}
|
||||
{{ text_field('Send letters') }}
|
||||
{{ boolean_field('letter' in current_service.permissions) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for(
|
||||
'.service_set_channel',
|
||||
channel='letter',
|
||||
service_id=current_service.id
|
||||
),
|
||||
permissions=['manage_service']
|
||||
)}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='letter') %}
|
||||
{{ text_field('Sender addresses') }}
|
||||
{% call field(status='' if current_service.count_letter_contact_details else 'default') %}
|
||||
{% if current_service.default_letter_contact_block %}
|
||||
{{ current_service.default_letter_contact_block_html }}
|
||||
{% elif current_service.count_letter_contact_details %}
|
||||
Blank
|
||||
{% else %}
|
||||
Not set
|
||||
{% endif %}
|
||||
{% if current_service.count_letter_contact_details > 1 %}
|
||||
<div class="hint">
|
||||
{{ '…and %d more' | format(current_service.count_letter_contact_details - 1) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{{ edit_field(
|
||||
'Manage',
|
||||
url_for('.service_letter_contact_details',
|
||||
service_id=current_service.id),
|
||||
permissions=['manage_service','manage_api_keys']
|
||||
)
|
||||
}}
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_row(if_has_permission='letter') %}
|
||||
{{ text_field('Letter branding') }}
|
||||
{{ optional_text_field(current_service.letter_branding.name) }}
|
||||
{{ edit_field(
|
||||
'Change',
|
||||
url_for('.branding_request', service_id=current_service.id, branding_type="letter"),
|
||||
permissions=['manage_service']
|
||||
)}}
|
||||
{% endcall %}
|
||||
|
||||
{% endcall %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if current_service.trial_mode %}
|
||||
<h2 class="heading-medium top-gutter-0">Your service is in trial mode</h2>
|
||||
|
||||
<p class="govuk-body">You can only:</p>
|
||||
{% if not current_service.has_permission('broadcast') %}
|
||||
<p class="govuk-body">You can only:</p>
|
||||
|
||||
<ul class='list list-bullet'>
|
||||
<li>send {{ current_service.message_limit }} text messages and emails per day</li>
|
||||
<li>send messages to yourself and other people in your team</li>
|
||||
<li>create letter templates, but not send them</li>
|
||||
</ul>
|
||||
<ul class='list list-bullet'>
|
||||
<li>send {{ current_service.message_limit }} text messages and emails per day</li>
|
||||
<li>send messages to yourself and other people in your team</li>
|
||||
<li>create letter templates, but not send them</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
<p class="govuk-body">
|
||||
{% if current_user.has_permissions('manage_service') %}
|
||||
@@ -269,11 +274,13 @@
|
||||
{% else %}
|
||||
<h2 class="heading-medium top-gutter-0">Your service is live</h2>
|
||||
|
||||
<p class="govuk-body">
|
||||
You can send up to
|
||||
{{ "{:,}".format(current_service.message_limit) }} messages
|
||||
per day.
|
||||
</p>
|
||||
{% if not current_service.has_permission('broadcast') %}
|
||||
<p class="govuk-body">
|
||||
You can send up to
|
||||
{{ "{:,}".format(current_service.message_limit) }} messages
|
||||
per day.
|
||||
</p>
|
||||
{% endif %}
|
||||
<p class="govuk-body">
|
||||
Problems or comments?
|
||||
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.support') }}">Give feedback</a>.
|
||||
|
||||
Reference in New Issue
Block a user