Allow sending sms to be disabled

Platform admins can now disable sending sms for a service. If sending
sms is disabled, this will also hide all the other sms options in the
Settings table.
This commit is contained in:
Katie Smith
2017-06-26 16:22:48 +01:00
parent 5986dfd415
commit 95f9d26e91
4 changed files with 128 additions and 60 deletions

View File

@@ -247,6 +247,14 @@ def service_switch_can_send_email(service_id):
return redirect(url_for('.service_settings', service_id=service_id))
@main.route("/services/<service_id>/service-settings/can-send-sms")
@login_required
@user_has_permissions(admin_override=True)
def service_switch_can_send_sms(service_id):
switch_service_permissions(service_id, 'sms')
return redirect(url_for('.service_settings', service_id=service_id))
@main.route("/services/<service_id>/service-settings/archive", methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_settings', admin_override=True)
@@ -335,6 +343,15 @@ def service_set_sms_sender(service_id):
form=form)
@main.route("/services/<service_id>/service-settings/set-sms", methods=['GET'])
@login_required
@user_has_permissions('manage_settings', admin_override=True)
def service_set_sms(service_id):
return render_template(
'views/service-settings/set-sms.html',
)
@main.route("/services/<service_id>/service-settings/set-international-sms", methods=['GET'])
@login_required
@user_has_permissions('manage_settings', admin_override=True)

View File

@@ -45,37 +45,47 @@
{% endif %}
{% call row() %}
{{ text_field('Text message sender') }}
{{ text_field(current_service.sms_sender) }}
{% if current_user.has_permissions([], admin_override=True) or not can_receive_inbound %}
{{ edit_field('Change', url_for('.service_set_sms_sender', service_id=current_service.id, set_inbound_sms=False)) }}
{% else %}
{{ text_field('') }}
{{ text_field('Send text messages') }}
{{ boolean_field('sms' in current_service.permissions) }}
{{ edit_field('Change', url_for('.service_set_sms', service_id=current_service.id)) }}
{% endcall %}
{% if 'sms' in current_service.permissions %}
{% call row() %}
{{ text_field('Text message sender') }}
{{ text_field(current_service.sms_sender) }}
{% if current_user.has_permissions([], admin_override=True) or not can_receive_inbound %}
{{ edit_field('Change', url_for('.service_set_sms_sender', service_id=current_service.id, set_inbound_sms=False)) }}
{% else %}
{{ text_field('') }}
{% endif %}
{% endcall %}
{% call row() %}
{{ text_field('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)) }}
{% endcall %}
{% call row() %}
{{ 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)) }}
{% endcall %}
{% if can_receive_inbound %}
{% call row() %}
{{ text_field('API endpoint for received text messages') }}
{{ text_field(
'None' if not inbound_api_url else inbound_api_url,
status='' if inbound_api_url else 'default'
) }}
{{ edit_field('Change', url_for('.service_set_inbound_api', service_id=current_service.id)) }}
{% endcall %}
{% endif %}
{% endcall %}
{% call row() %}
{{ text_field('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)) }}
{% endcall %}
{% call row() %}
{{ 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)) }}
{% endcall %}
{% if can_receive_inbound %}
{% call row() %}
{{ text_field('API endpoint for received text messages') }}
{{ text_field(
'None' if not inbound_api_url else inbound_api_url,
status='' if inbound_api_url else 'default'
) }}
{{ edit_field('Change', url_for('.service_set_inbound_api', service_id=current_service.id)) }}
{% endcall %}
{% endif %}
{% call row() %}
@@ -177,10 +187,22 @@
</a>
</li>
<li class="bottom-gutter">
<a href="{{ url_for('.service_switch_can_send_international_sms', service_id=current_service.id) }}" class="button">
{{ 'Stop sending international sms' if 'international_sms' in current_service.permissions else 'Allow international sms' }}
<a href="{{ url_for('.service_switch_can_send_sms', service_id=current_service.id) }}" class="button">
{{ 'Stop sending sms' if 'sms' in current_service.permissions else 'Allow to send sms' }}
</a>
</li>
{% if 'sms' in current_service.permissions %}
<li class="bottom-gutter">
<a href="{{ url_for('.service_switch_can_send_international_sms', service_id=current_service.id) }}" class="button">
{{ 'Stop sending international sms' if 'international_sms' in current_service.permissions else 'Allow to send international sms' }}
</a>
</li>
<li class="bottom-gutter">
<a href="{{ url_for('.service_set_sms_sender', service_id=current_service.id, set_inbound_sms=True) }}" class="button">
{{ 'Stop inbound sms' if can_receive_inbound else 'Allow inbound sms' }}
</a>
</li>
{% endif %}
{% if current_service.active %}
<li class="bottom-gutter">
<a href="{{ url_for('.archive_service', service_id=current_service.id) }}" class="button">
@@ -200,11 +222,6 @@
</a>
</li>
{% endif %}
<li class="bottom-gutter">
<a href="{{ url_for('.service_set_sms_sender', service_id=current_service.id, set_inbound_sms=True) }}" class="button">
{{ 'Stop inbound sms' if can_receive_inbound else 'Allow inbound sms' }}
</a>
</li>
</ul>
{% endif %}

View File

@@ -0,0 +1,38 @@
{% extends "withnav_template.html" %}
{% from "components/textbox.html" import textbox %}
{% from "components/page-footer.html" import page_footer %}
{% block service_page_title %}
Text messages
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row">
<div class="column-five-sixths">
<h1 class="heading-large">Text messages</h1>
{% if 'sms' in current_service.permissions %}
<p>
Your service can send text messages.
</p>
<p>
If you want to turn it off,
<a href="{{ url_for('.support') }}">get in touch with the GOV.UK Notify team</a>.
</p>
{% else %}
<p>
Sending text messages is an invitation&#8209;only feature.
</p>
<p>
If you want to try it out,
<a href="{{ url_for('.support') }}">get in touch with the GOV.UK Notify team</a>.
</p>
{% endif %}
{{ page_footer(
back_link=url_for('.service_settings', service_id=current_service.id),
back_link_text='Back to settings'
) }}
</div>
</div>
{% endblock %}