mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
DRY-up listing NHS organisation types
The model should be the source of truth for this.
This commit is contained in:
@@ -23,12 +23,16 @@ class Organisation(JSONModel, SortByNameMixin):
|
||||
TYPE_SCHOOL_OR_COLLEGE = 'school_or_college'
|
||||
TYPE_OTHER = 'other'
|
||||
|
||||
TYPES = (
|
||||
(TYPE_CENTRAL, 'Central government'),
|
||||
(TYPE_LOCAL, 'Local government'),
|
||||
NHS_TYPES = (
|
||||
(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'),
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from app.models.organisation import Organisation
|
||||
|
||||
NHS_TYPES = dict(Organisation.NHS_TYPES).keys()
|
||||
|
||||
|
||||
def get_email_choices(service):
|
||||
organisation_branding_id = service.organisation.email_branding_id if service.organisation else None
|
||||
@@ -22,22 +24,14 @@ def get_email_choices(service):
|
||||
yield ('govuk_and_org', 'GOV.UK and {}'.format(service.organisation.name))
|
||||
|
||||
if (
|
||||
service.organisation_type in {
|
||||
Organisation.TYPE_NHS_CENTRAL,
|
||||
Organisation.TYPE_NHS_LOCAL,
|
||||
Organisation.TYPE_NHS_GP,
|
||||
}
|
||||
service.organisation_type in NHS_TYPES
|
||||
and service_branding_name != 'NHS'
|
||||
):
|
||||
yield ('nhs', 'NHS')
|
||||
|
||||
if (
|
||||
service.organisation
|
||||
and service.organisation_type not in {
|
||||
Organisation.TYPE_NHS_LOCAL,
|
||||
Organisation.TYPE_NHS_CENTRAL,
|
||||
Organisation.TYPE_NHS_GP,
|
||||
}
|
||||
and service.organisation_type not in NHS_TYPES
|
||||
and (
|
||||
service_branding_id is None
|
||||
or service_branding_id != organisation_branding_id
|
||||
@@ -52,22 +46,14 @@ def get_letter_choices(service):
|
||||
service_branding_name = service.letter_branding_name
|
||||
|
||||
if (
|
||||
service.organisation_type in {
|
||||
Organisation.TYPE_NHS_CENTRAL,
|
||||
Organisation.TYPE_NHS_LOCAL,
|
||||
Organisation.TYPE_NHS_GP,
|
||||
}
|
||||
service.organisation_type in NHS_TYPES
|
||||
and service_branding_name != 'NHS'
|
||||
):
|
||||
yield ('nhs', 'NHS')
|
||||
|
||||
if (
|
||||
service.organisation
|
||||
and service.organisation_type not in {
|
||||
Organisation.TYPE_NHS_LOCAL,
|
||||
Organisation.TYPE_NHS_CENTRAL,
|
||||
Organisation.TYPE_NHS_GP,
|
||||
}
|
||||
and service.organisation_type not in NHS_TYPES
|
||||
and (
|
||||
service_branding_id is None
|
||||
or service_branding_id != organisation_branding_id
|
||||
|
||||
Reference in New Issue
Block a user