diff --git a/app/main/forms.py b/app/main/forms.py index 81a747cea..127cf8358 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -992,7 +992,7 @@ class OrganisationTypeField(GovukRadiosField): super().__init__( *args, choices=[ - (value, label) for value, label in Organisation.TYPES + (value, label) for value, label in Organisation.TYPE_LABELS.items() if not include_only or value in include_only ], thing='the type of organisation', diff --git a/app/models/organisation.py b/app/models/organisation.py index 32fab3dcf..e668053d4 100644 --- a/app/models/organisation.py +++ b/app/models/organisation.py @@ -1,3 +1,5 @@ +from collections import OrderedDict + from flask import abort from werkzeug.utils import cached_property @@ -24,19 +26,21 @@ class Organisation(JSONModel, SortByNameMixin): TYPE_OTHER = 'other' NHS_TYPES = ( + TYPE_NHS_CENTRAL, + TYPE_NHS_LOCAL, + TYPE_NHS_GP, + ) + + TYPE_LABELS = OrderedDict([ + (TYPE_CENTRAL, 'Central government'), + (TYPE_LOCAL, 'Local government'), (TYPE_NHS_CENTRAL, 'NHS – central government agency or public body'), (TYPE_NHS_LOCAL, 'NHS Trust or Clinical Commissioning Group'), (TYPE_NHS_GP, 'GP practice'), - ) - - TYPES = ( - (TYPE_CENTRAL, 'Central government'), - (TYPE_LOCAL, 'Local government'), - ) + NHS_TYPES + ( (TYPE_EMERGENCY_SERVICE, 'Emergency service'), (TYPE_SCHOOL_OR_COLLEGE, 'School or college'), (TYPE_OTHER, 'Other'), - ) + ]) ALLOWED_PROPERTIES = { 'id', @@ -112,7 +116,7 @@ class Organisation(JSONModel, SortByNameMixin): @property def organisation_type_label(self): - return dict(self.TYPES).get(self.organisation_type) + return self.TYPE_LABELS.get(self.organisation_type) @property def crown_status_or_404(self): diff --git a/app/models/service.py b/app/models/service.py index 2a995c6d8..9d1ca937b 100644 --- a/app/models/service.py +++ b/app/models/service.py @@ -519,7 +519,7 @@ class Service(JSONModel, SortByNameMixin): @property def organisation_type_label(self): - return dict(Organisation.TYPES).get(self.organisation_type) + return Organisation.TYPE_LABELS.get(self.organisation_type) @cached_property def inbound_number(self): diff --git a/app/utils/branding.py b/app/utils/branding.py index 7ecf8ef95..11b4981b9 100644 --- a/app/utils/branding.py +++ b/app/utils/branding.py @@ -1,6 +1,5 @@ from app.models.organisation import Organisation -NHS_TYPES = dict(Organisation.NHS_TYPES).keys() NHS_EMAIL_BRANDING_ID = 'a7dc4e56-660b-4db7-8cff-12c37b12b5ea' @@ -23,14 +22,14 @@ def get_email_choices(service): yield ('govuk_and_org', f'GOV.UK and {service.organisation.name}') if ( - service.organisation_type in NHS_TYPES + service.organisation_type in Organisation.NHS_TYPES and service.email_branding_id != NHS_EMAIL_BRANDING_ID ): yield ('nhs', 'NHS') if ( service.organisation - and service.organisation_type not in NHS_TYPES + and service.organisation_type not in Organisation.NHS_TYPES and ( service.email_branding_id is None # GOV.UK is current branding or service.email_branding_id != organisation_branding_id @@ -43,14 +42,14 @@ def get_letter_choices(service): organisation_branding_id = service.organisation.letter_branding_id if service.organisation else None if ( - service.organisation_type in NHS_TYPES + service.organisation_type in Organisation.NHS_TYPES and service.letter_branding_name != 'NHS' ): yield ('nhs', 'NHS') if ( service.organisation - and service.organisation_type not in NHS_TYPES + and service.organisation_type not in Organisation.NHS_TYPES and ( service.letter_branding_id is None # GOV.UK is current branding or service.letter_branding_id != organisation_branding_id