Merge pull request #3307 from alphagov/send-by-email-setting

Users now able to set the send by email setting by themselves
This commit is contained in:
Pea M. Tyczynska
2020-02-27 16:15:16 +00:00
committed by GitHub
13 changed files with 144 additions and 195 deletions

View File

@@ -67,7 +67,6 @@ from app.utils import (
PLATFORM_ADMIN_SERVICE_PERMISSIONS = OrderedDict([
('inbound_sms', {'title': 'Receive inbound SMS', 'requires': 'sms', 'endpoint': '.service_set_inbound_number'}),
('email_auth', {'title': 'Email authentication'}),
('upload_document', {'title': 'Send files by email', 'endpoint': '.service_switch_can_upload_document'}),
('upload_letters', {'title': 'Uploading letters', 'requires': 'letter'}),
])
@@ -294,26 +293,6 @@ def service_set_permission(service_id, permission):
)
@main.route("/services/<uuid:service_id>/service-settings/can-upload-document", methods=['GET', 'POST'])
@user_is_platform_admin
def service_switch_can_upload_document(service_id):
if current_service.contact_link:
return redirect(url_for('.service_set_permission', service_id=service_id, permission='upload_document'))
form = ServiceContactDetailsForm()
if form.validate_on_submit():
contact_type = form.contact_details_type.data
current_service.update(
contact_link=form.data[contact_type]
)
return redirect(url_for('.service_set_permission', service_id=service_id, permission='upload_document'))
return render_template('views/service-settings/contact_link.html', form=form)
@main.route("/services/<uuid:service_id>/service-settings/archive", methods=['GET', 'POST'])
@user_has_permissions('manage_service')
def archive_service(service_id):
@@ -359,18 +338,20 @@ def resume_service(service_id):
return service_settings(service_id)
@main.route("/services/<uuid:service_id>/service-settings/contact-link", methods=['GET', 'POST'])
@main.route("/services/<uuid:service_id>/service-settings/send-files-by-email", methods=['GET', 'POST'])
@user_has_permissions('manage_service')
def service_set_contact_link(service_id):
def send_files_by_email_contact_details(service_id):
form = ServiceContactDetailsForm()
contact_details = None
if request.method == 'GET':
contact_details = current_service.contact_link
contact_type = check_contact_details_type(contact_details)
field_to_update = getattr(form, contact_type)
if contact_details:
contact_type = check_contact_details_type(contact_details)
field_to_update = getattr(form, contact_type)
form.contact_details_type.data = contact_type
field_to_update.data = contact_details
form.contact_details_type.data = contact_type
field_to_update.data = contact_details
if form.validate_on_submit():
contact_type = form.contact_details_type.data
@@ -380,7 +361,9 @@ def service_set_contact_link(service_id):
)
return redirect(url_for('.service_settings', service_id=current_service.id))
return render_template('views/service-settings/contact_link.html', form=form)
return render_template(
'views/service-settings/send-files-by-email.html', form=form, contact_details=contact_details
)
@main.route("/services/<uuid:service_id>/service-settings/set-reply-to-email", methods=['GET'])

View File

@@ -287,7 +287,7 @@ class HeaderNavigation(Navigation):
'service_preview_letter_branding',
'service_set_auth_type',
'service_set_channel',
'service_set_contact_link',
'send_files_by_email_contact_details',
'service_set_email_branding',
'service_set_inbound_number',
'service_set_inbound_sms',
@@ -299,7 +299,6 @@ class HeaderNavigation(Navigation):
'service_set_sms_prefix',
'service_settings',
'service_sms_senders',
'service_switch_can_upload_document',
'service_switch_count_as_live',
'service_switch_live',
'service_set_permission',
@@ -433,7 +432,7 @@ class MainNavigation(Navigation):
'service_preview_letter_branding',
'service_set_auth_type',
'service_set_channel',
'service_set_contact_link',
'send_files_by_email_contact_details',
'service_set_email_branding',
'service_set_inbound_number',
'service_set_inbound_sms',
@@ -593,7 +592,6 @@ class MainNavigation(Navigation):
'service_delete_letter_contact',
'service_delete_sms_sender',
'service_download_agreement',
'service_switch_can_upload_document',
'service_switch_count_as_live',
'service_switch_live',
'service_set_permission',
@@ -865,7 +863,7 @@ class CaseworkNavigation(Navigation):
'service_preview_letter_branding',
'service_set_auth_type',
'service_set_channel',
'service_set_contact_link',
'send_files_by_email_contact_details',
'service_set_email_branding',
'service_set_inbound_number',
'service_set_inbound_sms',
@@ -876,7 +874,6 @@ class CaseworkNavigation(Navigation):
'service_set_sms_prefix',
'service_settings',
'service_sms_senders',
'service_switch_can_upload_document',
'service_switch_count_as_live',
'service_switch_live',
'service_set_permission',
@@ -1155,7 +1152,7 @@ class OrgNavigation(Navigation):
'service_preview_letter_branding',
'service_set_auth_type',
'service_set_channel',
'service_set_contact_link',
'send_files_by_email_contact_details',
'service_set_email_branding',
'service_set_inbound_number',
'service_set_inbound_sms',
@@ -1166,7 +1163,6 @@ class OrgNavigation(Navigation):
'service_set_sms_prefix',
'service_settings',
'service_sms_senders',
'service_switch_can_upload_document',
'service_switch_count_as_live',
'service_switch_live',
'service_set_permission',

View File

@@ -8,8 +8,8 @@
<h1 class="heading-large">Send files by email</h1>
<p><a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('.support') }}">Contact us</a> if you want to send files by email.</p>
<p>To send a file by email, follow the instructions in our <a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('.documentation') }}">API documentation</a>.</p>
<p>Then follow the instructions to send a file by email in our <a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('.documentation') }}">API documentation</a>.</p>
<p>This is an API-only feature.</p>
{% endblock %}

View File

@@ -45,19 +45,6 @@
)
}}
{% endcall %}
{% call settings_row(if_has_permission='upload_document') %}
{{ text_field('Contact details') }}
{{ text_field(current_service.contact_link, truncate=true) }}
{{ edit_field(
'Change',
url_for('.service_set_contact_link',
service_id=current_service.id),
permissions=['manage_service']
)
}}
{% endcall %}
{% endcall %}
{% call mapping_table(
@@ -110,6 +97,16 @@
)}}
{% 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(

View File

@@ -7,20 +7,25 @@
{% from "components/form.html" import form_wrapper %}
{% block service_page_title %}
{{ 'Change' if 'upload_document' in current_service.permissions else 'Add' }} contact details for Download your document page
Send files by email
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row">
<div class="column-five-sixths">
{{ page_header(
'{} contact details for Download your document page'.format('Change' if 'upload_document' in current_service.permissions else 'Add'),
'Send files by email',
back_link=url_for('main.service_settings', service_id=current_service.id)
) }}
<p>
When you send users a document to download, you need to include the contact details for your service
on the download page. This is so users can contact you if theres a problem (for example,
if the link to download the document has expired).
This is an API-only feature.
</p>
<p>
To send a file by email, follow the instructions in our <a href={{ url_for('main.documentation') }}>API documentation</a>.
</p>
<h2 class="heading-medium">{% if contact_details %}Change contact details for{% else %}Add contact details to{% endif %} the file download page</h2>
<p>
You need to include contact details for your service so your users can get in touch if theres a problem. For example, if the link to download the file you sent them has expired.
</p>
{% call form_wrapper() %}