Make separate endpoints for GOV.UK email branding options

The endpoint to change the email branding to "GOV.UK" branding and
"GOV.UK and organisation" branding was the same but with a query string
used to determine which of the two options had been selected. This makes
them two separate endpoints, which makes the code a bit simpler and
hopefully means there is less chance of things not working as expected.
This commit is contained in:
Katie Smith
2022-02-03 11:31:25 +00:00
parent 194fec9009
commit a7a593fd8b
4 changed files with 32 additions and 39 deletions

View File

@@ -1168,19 +1168,10 @@ def email_branding_request(service_id):
flash('Thanks for your branding request. Well 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/<uuid:service_id>/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. Well 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/<uuid:service_id>/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. Well 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/<uuid:service_id>/service-settings/email-branding/nhs", methods=['GET', 'POST'])