From d75c1ea398f357802e6dbd516603dd9874717b78 Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Thu, 17 Feb 2022 14:52:24 +0000 Subject: [PATCH] Split out the govuk and govuk_and_org branding templates The `.email_branding_govuk` and `.email_branding_govuk_and_org` routes shared a template since the content was the same - the only difference was in the action of the button. However, since the pages will no longer be so similar (e.g. the govuk page will show a preview) this splits them up to use separate templates. It may be the case that when the branding work is complete these pages are fairly similar and we decided that one template between the two endpoints is the best option again. --- app/main/views/service_settings.py | 6 +- .../branding/email-branding-govuk-org.html | 43 ++++++++++++ .../branding/email-branding-govuk.html | 2 +- tests/app/main/views/test_service_settings.py | 68 ++++++++++++++++--- 4 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 app/templates/views/service-settings/branding/email-branding-govuk-org.html diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index b667b3777..76183ae3a 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -1196,7 +1196,7 @@ def email_branding_govuk(service_id): check_branding_allowed_for_service('govuk') if request.method == 'POST': - create_email_branding_zendesk_ticket(request.form['branding_choice']) + create_email_branding_zendesk_ticket('govuk') flash('Thanks for your branding request. We’ll get back to you within one working day.', 'default') return redirect(url_for('.service_settings', service_id=current_service.id)) @@ -1210,12 +1210,12 @@ def email_branding_govuk_and_org(service_id): check_branding_allowed_for_service('govuk_and_org') if request.method == 'POST': - create_email_branding_zendesk_ticket(request.form['branding_choice']) + create_email_branding_zendesk_ticket('govuk_and_org') flash('Thanks for your branding request. We’ll get back to you within one working day.', 'default') return redirect(url_for('.service_settings', service_id=current_service.id)) - return render_template('views/service-settings/branding/email-branding-govuk.html', with_org=True) + return render_template('views/service-settings/branding/email-branding-govuk-org.html') @main.route("/services//service-settings/email-branding/nhs", methods=['GET', 'POST']) diff --git a/app/templates/views/service-settings/branding/email-branding-govuk-org.html b/app/templates/views/service-settings/branding/email-branding-govuk-org.html new file mode 100644 index 000000000..3fc667faa --- /dev/null +++ b/app/templates/views/service-settings/branding/email-branding-govuk-org.html @@ -0,0 +1,43 @@ +{% extends "withnav_template.html" %} +{% from "components/form.html" import form_wrapper %} +{% from "components/back-link/macro.njk" import govukBackLink %} +{% from "components/page-footer.html" import page_footer %} +{% from "components/page-header.html" import page_header %} + +{% block service_page_title %} + Before you request new branding +{% endblock %} + +{% block backLink %} + {{ govukBackLink({ + "href": url_for('.email_branding_request', service_id=current_service.id) + }) }} +{% endblock %} + +{% block maincolumn_content %} + + {{ page_header('Before you request new branding') }} + +

Check that your new branding matches the rest of your service.

+ +

You can use the GOV.UK logo on your emails if:

+ + +

+ You cannot use GOV.UK branding if your organisation is + independent + from government. +

+ +

We’ll email you once your branding’s ready to use, or if we need any more information.

+ + {% call form_wrapper() %} + {{ page_footer('Request new branding') }} + {% endcall %} + +{% endblock %} diff --git a/app/templates/views/service-settings/branding/email-branding-govuk.html b/app/templates/views/service-settings/branding/email-branding-govuk.html index 925331902..3fc667faa 100644 --- a/app/templates/views/service-settings/branding/email-branding-govuk.html +++ b/app/templates/views/service-settings/branding/email-branding-govuk.html @@ -37,7 +37,7 @@

We’ll email you once your branding’s ready to use, or if we need any more information.

{% call form_wrapper() %} - {{ page_footer('Request new branding', button_name='branding_choice', button_value=('govuk_and_org' if with_org else 'govuk')) }} + {{ page_footer('Request new branding') }} {% endcall %} {% endblock %} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index bb94c099d..4cf9184d9 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -5495,10 +5495,6 @@ def test_get_email_branding_description_pages_give_404_if_selected_branding_not_ ) -@pytest.mark.parametrize('branding_choice, branding_description', [ - ('govuk', 'GOV.UK'), - ('govuk_and_org', 'GOV.UK and organisation one'), -]) def test_submit_email_branding_request_from_govuk_description_page( mocker, client_request, @@ -5508,8 +5504,6 @@ def test_submit_email_branding_request_from_govuk_description_page( no_reply_to_email_addresses, mock_get_email_branding, single_sms_sender, - branding_choice, - branding_description, ): mocker.patch( 'app.organisations_client.get_organisation', @@ -5531,7 +5525,6 @@ def test_submit_email_branding_request_from_govuk_description_page( page = client_request.post( '.email_branding_govuk', service_id=SERVICE_ONE_ID, - _data={'branding_choice': branding_choice}, _follow_redirects=True, ) @@ -5544,7 +5537,66 @@ def test_submit_email_branding_request_from_govuk_description_page( '', '---', 'Current branding: Organisation name', - f'Branding requested: {branding_description}\n', + 'Branding requested: GOV.UK\n', + ]), + subject='Email branding request - service one', + ticket_type='question', + user_name='Test User', + user_email='test@user.gov.uk', + org_id=ORGANISATION_ID, + org_type='central', + service_id=SERVICE_ONE_ID + ) + mock_send_ticket_to_zendesk.assert_called_once() + assert normalize_spaces(page.select_one('.banner-default').text) == ( + 'Thanks for your branding request. We’ll get back to you ' + 'within one working day.' + ) + + +def test_submit_email_branding_request_from_govuk_and_org_description_page( + mocker, + client_request, + service_one, + organisation_one, + mock_get_service_settings_page_common, + no_reply_to_email_addresses, + mock_get_email_branding, + single_sms_sender, +): + mocker.patch( + 'app.organisations_client.get_organisation', + return_value=organisation_one, + ) + mocker.patch( + 'app.models.service.Service.organisation_id', + new_callable=PropertyMock, + return_value=ORGANISATION_ID, + ) + service_one['email_branding'] = sample_uuid() + + mock_create_ticket = mocker.spy(NotifySupportTicket, '__init__') + mock_send_ticket_to_zendesk = mocker.patch( + 'app.main.views.service_settings.zendesk_client.send_ticket_to_zendesk', + autospec=True, + ) + + page = client_request.post( + '.email_branding_govuk_and_org', + service_id=SERVICE_ONE_ID, + _follow_redirects=True, + ) + + mock_create_ticket.assert_called_once_with( + ANY, + message='\n'.join([ + 'Organisation: organisation one', + 'Service: service one', + 'http://localhost/services/596364a0-858e-42c8-9062-a8fe822260eb', + '', + '---', + 'Current branding: Organisation name', + 'Branding requested: GOV.UK and organisation one\n', ]), subject='Email branding request - service one', ticket_type='question',