mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-27 17:39:51 -04:00
Decouple the set of org types from their labels
In response to: [^1]. [^1]: https://github.com/alphagov/notifications-admin/pull/4196#discussion_r838383086
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user