From 61ccc8ad51c29beaaaffe605f3e98ddb7704391e Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 3 Apr 2017 10:28:23 +0100 Subject: [PATCH 1/4] Remove contact block guidance from edit page This page is not the place where you edit the contact details. Nor is it the place where you can preview changes to the contact block. In research users never found the link to get from this page to the edit contact details page. So this commit removes it. --- .../partials/templates/guidance-contact-block.html | 8 -------- app/templates/views/edit-letter-template.html | 1 - 2 files changed, 9 deletions(-) delete mode 100644 app/templates/partials/templates/guidance-contact-block.html diff --git a/app/templates/partials/templates/guidance-contact-block.html b/app/templates/partials/templates/guidance-contact-block.html deleted file mode 100644 index dda2aa91f..000000000 --- a/app/templates/partials/templates/guidance-contact-block.html +++ /dev/null @@ -1,8 +0,0 @@ -

Contact details

-

- Add contact details for your service in - settings. -

-

- The text will appear in the top right of all letters your service sends. -

diff --git a/app/templates/views/edit-letter-template.html b/app/templates/views/edit-letter-template.html index 28217c529..a44895432 100644 --- a/app/templates/views/edit-letter-template.html +++ b/app/templates/views/edit-letter-template.html @@ -29,7 +29,6 @@ From b5127967feb11d8298f35f0502751463b26d4941 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 3 Apr 2017 10:46:41 +0100 Subject: [PATCH 2/4] Make page title match H1 on letter contact details --- .../views/service-settings/set-letter-contact-block.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/views/service-settings/set-letter-contact-block.html b/app/templates/views/service-settings/set-letter-contact-block.html index 283f19867..d7c8168fd 100644 --- a/app/templates/views/service-settings/set-letter-contact-block.html +++ b/app/templates/views/service-settings/set-letter-contact-block.html @@ -3,7 +3,7 @@ {% from "components/page-footer.html" import page_footer %} {% block service_page_title %} - Letter contact block + Letter contact details {% endblock %} {% block maincolumn_content %} From 1f278bdd077721da692ccbf22641effe0b63bd4d Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 3 Apr 2017 09:54:03 +0100 Subject: [PATCH 3/4] Go back to template after editing contact details MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users who go to edit the contact details for a letter from the template page get very confused when they click save and are dumped on the settings page. It doesn’t match the way editing other parts of letter works, and you can’t see an accurate preview of the changes from the settings page. So this commit changes the flow to go from the _edit contact details_ page back to the _view template_ page when the user has got there by clicking the blue _Edit_ button on the _view template_ page. --- app/main/views/service_settings.py | 4 +++ app/templates/views/templates/_template.html | 2 +- tests/app/main/views/test_service_settings.py | 25 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 5c8f83ae3..abc6dd620 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -275,6 +275,10 @@ def service_set_letter_contact_block(service_id): current_service['id'], letter_contact_block=form.letter_contact_block.data.replace('\r', '') or None ) + if request.args.get('from_template'): + return redirect( + url_for('.view_template', service_id=service_id, template_id=request.args.get('from_template')) + ) return redirect(url_for('.service_settings', service_id=service_id)) return render_template( 'views/service-settings/set-letter-contact-block.html', diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html index f7c05eac9..76e533474 100644 --- a/app/templates/views/templates/_template.html +++ b/app/templates/views/templates/_template.html @@ -35,7 +35,7 @@
{% if current_user.has_permissions(permissions=['manage_templates'], admin_override=True) and template.template_type == 'letter' %} Edit - Edit + Edit Edit {% endif %} {{ template|string }} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 9fd2b4252..dfcbac884 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -1,6 +1,7 @@ from unittest.mock import call, ANY, Mock import pytest +import uuid from flask import url_for from bs4 import BeautifulSoup from werkzeug.exceptions import InternalServerError @@ -619,6 +620,30 @@ def test_set_letter_contact_block_saves( mock_update_service.assert_called_once_with(service_one['id'], letter_contact_block='foo bar baz waz') +def test_set_letter_contact_block_redirects_to_template( + logged_in_client, + service_one, + mock_update_service, +): + service_one['can_send_letters'] = True + fake_template_id = uuid.uuid4() + response = logged_in_client.post( + url_for( + 'main.service_set_letter_contact_block', + service_id=service_one['id'], + from_template=fake_template_id, + ), + data={'letter_contact_block': ''}, + ) + assert response.status_code == 302 + assert response.location == url_for( + 'main.view_template', + service_id=service_one['id'], + template_id=fake_template_id, + _external=True, + ) + + def test_set_letter_contact_block_has_max_10_lines( logged_in_client, service_one, From 2f900d55c5697893234304d10b6c0d10074cfd4c Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 3 Apr 2017 10:46:21 +0100 Subject: [PATCH 4/4] Explain contact details changes apply all letters This is different to how editing most parts of a letter works, so we should make it explicit. --- app/main/forms.py | 4 +--- .../views/service-settings/set-letter-contact-block.html | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index cb5c9943a..d303b3673 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -502,9 +502,7 @@ class ServiceSmsSender(Form): class ServiceLetterContactBlock(Form): - letter_contact_block = TextAreaField( - 'How should users contact you?' - ) + letter_contact_block = TextAreaField() def validate_letter_contact_block(form, field): line_count = field.data.strip().count('\n') diff --git a/app/templates/views/service-settings/set-letter-contact-block.html b/app/templates/views/service-settings/set-letter-contact-block.html index d7c8168fd..33633e0f5 100644 --- a/app/templates/views/service-settings/set-letter-contact-block.html +++ b/app/templates/views/service-settings/set-letter-contact-block.html @@ -15,6 +15,7 @@
{{ textbox( form.letter_contact_block, + label='How should users contact your service?
This applies to all the letters you send.'|safe, hint='10 lines maximum', width='1-1', rows=10