Move and clarify "NHS_BRANDING_ID" constant

This is specific to email branding [^1]. Using the name to match
the current branding is more error-prone.

[^1]: a165f62b60
This commit is contained in:
Ben Thorner
2022-03-22 17:20:02 +00:00
parent 21eea0189d
commit 1cc5413f96
3 changed files with 13 additions and 12 deletions

View File

@@ -69,6 +69,7 @@ from app.main.forms import (
SomethingElseBrandingForm,
)
from app.utils import DELIVERED_STATUSES, FAILURE_STATUSES, SENDING_STATUSES
from app.utils.branding import NHS_EMAIL_BRANDING_ID
from app.utils.user import (
user_has_permissions,
user_is_gov_user,
@@ -81,8 +82,6 @@ PLATFORM_ADMIN_SERVICE_PERMISSIONS = OrderedDict([
('international_letters', {'title': 'Send international letters', 'requires': 'letter'}),
])
NHS_BRANDING_ID = 'a7dc4e56-660b-4db7-8cff-12c37b12b5ea'
@main.route("/services/<uuid:service_id>/service-settings")
@user_has_permissions('manage_service', 'manage_api_keys')
@@ -1219,12 +1218,15 @@ def email_branding_nhs(service_id):
check_email_branding_allowed_for_service('nhs')
if request.method == 'POST':
current_service.update(email_branding=NHS_BRANDING_ID)
current_service.update(email_branding=NHS_EMAIL_BRANDING_ID)
flash('Youve updated your email branding', 'default')
return redirect(url_for('.service_settings', service_id=current_service.id))
return render_template('views/service-settings/branding/email-branding-nhs.html', nhs_branding_id=NHS_BRANDING_ID)
return render_template(
'views/service-settings/branding/email-branding-nhs.html',
nhs_branding_id=NHS_EMAIL_BRANDING_ID
)
@main.route("/services/<uuid:service_id>/service-settings/email-branding/organisation", methods=['GET', 'POST'])

View File

@@ -1,12 +1,12 @@
from app.models.organisation import Organisation
NHS_TYPES = dict(Organisation.NHS_TYPES).keys()
NHS_EMAIL_BRANDING_ID = 'a7dc4e56-660b-4db7-8cff-12c37b12b5ea'
def get_email_choices(service):
organisation_branding_id = service.organisation.email_branding_id if service.organisation else None
service_branding_id = service.email_branding_id
service_branding_name = service.email_branding_name
if (
service.organisation_type == Organisation.TYPE_CENTRAL
@@ -19,13 +19,13 @@ def get_email_choices(service):
service.organisation_type == Organisation.TYPE_CENTRAL
and service.organisation
and organisation_branding_id is None
and service_branding_name.lower() != 'GOV.UK and {}'.format(service.organisation.name).lower()
and service.email_branding_name.lower() != 'GOV.UK and {}'.format(service.organisation.name).lower()
):
yield ('govuk_and_org', 'GOV.UK and {}'.format(service.organisation.name))
if (
service.organisation_type in NHS_TYPES
and service_branding_name != 'NHS'
and service_branding_id != NHS_EMAIL_BRANDING_ID
):
yield ('nhs', 'NHS')
@@ -43,11 +43,10 @@ def get_email_choices(service):
def get_letter_choices(service):
organisation_branding_id = service.organisation.letter_branding_id if service.organisation else None
service_branding_id = service.letter_branding_id
service_branding_name = service.letter_branding_name
if (
service.organisation_type in NHS_TYPES
and service_branding_name != 'NHS'
and service.letter_branding_name != 'NHS'
):
yield ('nhs', 'NHS')