Allow sending emails to be disabled

Platform admins can now disable sending of emails for a service. If
sending emails is disabled, this will also hide the option to change the
Email reply to address.
This commit is contained in:
Katie Smith
2017-06-26 15:22:06 +01:00
parent 11adf17330
commit 5986dfd415
4 changed files with 120 additions and 8 deletions

View File

@@ -239,6 +239,14 @@ def service_switch_can_send_international_sms(service_id):
return redirect(url_for('.service_settings', service_id=service_id))
@main.route("/services/<service_id>/service-settings/can-send-email")
@login_required
@user_has_permissions(admin_override=True)
def service_switch_can_send_email(service_id):
switch_service_permissions(service_id, 'email')
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)
@@ -276,6 +284,15 @@ def resume_service(service_id):
return service_settings(service_id)
@main.route("/services/<service_id>/service-settings/set-email", methods=['GET'])
@login_required
@user_has_permissions('manage_settings', admin_override=True)
def service_set_email(service_id):
return render_template(
'views/service-settings/set-email.html',
)
@main.route("/services/<service_id>/service-settings/set-reply-to-email", methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_settings', admin_override=True)

View File

@@ -26,14 +26,24 @@
{% endcall %}
{% call row() %}
{{ text_field('Email reply to address') }}
{{ text_field(
current_service.reply_to_email_address,
status='' if current_service.reply_to_email_address else 'default'
) }}
{{ edit_field('Change', url_for('.service_set_reply_to_email', service_id=current_service.id)) }}
{{ text_field('Send emails') }}
{{ boolean_field('email' in current_service.permissions) }}
{{ edit_field('Change', url_for('.service_set_email', service_id=current_service.id)) }}
{% endcall %}
{% if 'email' in current_service.permissions %}
{% call row() %}
{{ text_field('Email reply to address') }}
{{ text_field(
current_service.reply_to_email_address,
status='' if current_service.reply_to_email_address else 'default'
) }}
{{ edit_field('Change', url_for('.service_set_reply_to_email', service_id=current_service.id)) }}
{% endcall %}
{% endif %}
{% call row() %}
{{ text_field('Text message sender') }}
{{ text_field(current_service.sms_sender) }}
@@ -156,6 +166,11 @@
{{ 'Take service out of research mode' if current_service.research_mode else 'Put into research mode' }}
</a>
</li>
<li class="bottom-gutter">
<a href="{{ url_for('.service_switch_can_send_email', service_id=current_service.id) }}" class="button">
{{ 'Stop sending emails' if 'email' in current_service.permissions else 'Allow to send emails' }}
</a>
</li>
<li class="bottom-gutter">
<a href="{{ url_for('.service_switch_can_send_letters', service_id=current_service.id) }}" class="button">
{{ 'Stop sending letters' if 'letter' in current_service.permissions else 'Allow to send letters' }}

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 %}
Emails
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row">
<div class="column-five-sixths">
<h1 class="heading-large">Emails</h1>
{% if 'email' in current_service.permissions %}
<p>
Your service can send emails.
</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 emails 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 %}