diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index c166d357c..b667b3777 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -1168,19 +1168,10 @@ def email_branding_request(service_id): 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)) else: - endpoint = { - 'govuk': '.email_branding_govuk', - 'govuk_and_org': '.email_branding_govuk', - 'nhs': '.email_branding_nhs', - 'organisation': '.email_branding_organisation', - 'something_else': '.email_branding_something_else', - }[form.options.data] - return redirect( url_for( - endpoint, + f'.email_branding_{form.options.data}', service_id=current_service.id, - with_org=(True if form.options.data == 'govuk_and_org' else None), ) ) @@ -1202,9 +1193,7 @@ def check_branding_allowed_for_service(branding): @main.route("/services//service-settings/email-branding/govuk", methods=['GET', 'POST']) @user_has_permissions('manage_service') def email_branding_govuk(service_id): - with_org = request.args.get('with_org') - - check_branding_allowed_for_service('govuk_and_org' if with_org else 'govuk') + check_branding_allowed_for_service('govuk') if request.method == 'POST': create_email_branding_zendesk_ticket(request.form['branding_choice']) @@ -1212,7 +1201,21 @@ def email_branding_govuk(service_id): 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=with_org) + return render_template('views/service-settings/branding/email-branding-govuk.html') + + +@main.route("/services//service-settings/email-branding/govuk-and-org", methods=['GET', 'POST']) +@user_has_permissions('manage_service') +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']) + + 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) @main.route("/services//service-settings/email-branding/nhs", methods=['GET', 'POST']) 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 55efd6095..925331902 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 == 'True' else 'govuk')) }} + {{ page_footer('Request new branding', button_name='branding_choice', button_value=('govuk_and_org' if with_org else 'govuk')) }} {% endcall %} {% endblock %} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 36639693b..bb94c099d 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -5105,14 +5105,13 @@ def test_show_branding_request_page_when_branding_is_same_as_org( assert page.select_one('textarea')['name'] == 'something_else' -@pytest.mark.parametrize('data, org_type, endpoint, expect_with_org_query_param', ( +@pytest.mark.parametrize('data, org_type, endpoint', ( ( { 'options': 'govuk', }, 'central', 'main.email_branding_govuk', - False ), ( { @@ -5121,15 +5120,13 @@ def test_show_branding_request_page_when_branding_is_same_as_org( }, 'central', 'main.email_branding_govuk', - False ), ( { 'options': 'govuk_and_org', }, 'central', - 'main.email_branding_govuk', - True + 'main.email_branding_govuk_and_org', ), ( { @@ -5137,7 +5134,6 @@ def test_show_branding_request_page_when_branding_is_same_as_org( }, 'central', 'main.email_branding_organisation', - False ), ( { @@ -5145,7 +5141,6 @@ def test_show_branding_request_page_when_branding_is_same_as_org( }, 'central', 'main.email_branding_something_else', - False ), ( { @@ -5153,7 +5148,6 @@ def test_show_branding_request_page_when_branding_is_same_as_org( }, 'nhs_local', 'main.email_branding_nhs', - False ), )) def test_submit_email_branding_request_when_something_else_is_not_the_only_option( @@ -5165,7 +5159,6 @@ def test_submit_email_branding_request_when_something_else_is_not_the_only_optio data, org_type, endpoint, - expect_with_org_query_param, ): organisation_one['organisation_type'] = org_type service_one['email_branding'] = sample_uuid() @@ -5184,7 +5177,6 @@ def test_submit_email_branding_request_when_something_else_is_not_the_only_optio _expected_redirect=url_for( endpoint, service_id=SERVICE_ONE_ID, - with_org=(True if expect_with_org_query_param else None), _external=True, ) ) @@ -5440,11 +5432,12 @@ def test_submit_branding_when_something_else_is_only_option( ) in mock_create_ticket.call_args_list[0][1]['message'] -@pytest.mark.parametrize('endpoint, query_param, service_org_type, expected_heading', [ - ('main.email_branding_govuk', False, 'central', 'Before you request new branding'), - ('main.email_branding_govuk', True, 'central', 'Before you request new branding'), - ('main.email_branding_nhs', False, 'nhs_local', 'Before you request new branding'), - ('main.email_branding_organisation', 'central', False, 'When you request new branding'), +@pytest.mark.parametrize('endpoint, service_org_type, expected_heading', [ + ('main.email_branding_govuk', 'central', 'Before you request new branding'), + ('main.email_branding_govuk_and_org', 'central', 'Before you request new branding'), + ('main.email_branding_govuk', 'central', 'Before you request new branding'), + ('main.email_branding_nhs', 'nhs_local', 'Before you request new branding'), + ('main.email_branding_organisation', 'central', 'When you request new branding'), ]) def test_get_email_branding_description_pages( client_request, @@ -5453,7 +5446,6 @@ def test_get_email_branding_description_pages( organisation_one, mock_get_email_branding, endpoint, - query_param, service_org_type, expected_heading, ): @@ -5469,7 +5461,6 @@ def test_get_email_branding_description_pages( page = client_request.get( endpoint, service_id=SERVICE_ONE_ID, - with_org=(True if query_param else None) ) assert page.h1.text == expected_heading assert normalize_spaces(page.select_one('.page-footer button').text) == 'Request new branding' @@ -5485,23 +5476,21 @@ def test_get_email_branding_something_else_page(client_request): assert normalize_spaces(page.select_one('.page-footer button').text) == 'Request new branding' -@pytest.mark.parametrize('endpoint, query_param', [ - ('main.email_branding_govuk', False), - ('main.email_branding_govuk', True), - ('main.email_branding_nhs', False), - ('main.email_branding_organisation', False), +@pytest.mark.parametrize('endpoint', [ + ('main.email_branding_govuk'), + ('main.email_branding_govuk_and_org'), + ('main.email_branding_nhs'), + ('main.email_branding_organisation'), ]) def test_get_email_branding_description_pages_give_404_if_selected_branding_not_allowed( client_request, endpoint, - query_param, ): # The only email branding allowed is 'something_else', so trying to visit any of the other # endpoints gives a 404 status code. client_request.get( endpoint, service_id=SERVICE_ONE_ID, - with_org=(True if query_param else None), _expected_status=404 ) diff --git a/tests/app/test_navigation.py b/tests/app/test_navigation.py index 9a3684030..2cc4058fa 100644 --- a/tests/app/test_navigation.py +++ b/tests/app/test_navigation.py @@ -112,6 +112,7 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'edit_user_permissions', 'email_branding', 'email_branding_govuk', + 'email_branding_govuk_and_org', 'email_branding_nhs', 'email_branding_organisation', 'email_branding_request',