2023-07-12 12:09:44 -04:00
|
|
|
from app.models.organization import Organization
|
2022-03-03 12:51:38 +00:00
|
|
|
|
|
|
|
|
|
2022-03-22 16:56:50 +00:00
|
|
|
def get_email_choices(service):
|
2023-08-25 09:12:23 -07:00
|
|
|
organization_branding_id = (
|
|
|
|
|
service.organization.email_branding_id if service.organization else None
|
|
|
|
|
)
|
2022-03-03 12:51:38 +00:00
|
|
|
|
|
|
|
|
if (
|
2023-07-12 12:09:44 -04:00
|
|
|
service.organization_type == Organization.TYPE_FEDERAL
|
2022-03-22 17:29:39 +00:00
|
|
|
and service.email_branding_id is not None # GOV.UK is not current branding
|
2023-07-12 12:09:44 -04:00
|
|
|
and organization_branding_id is None # no default to supersede it (GOV.UK)
|
2022-03-03 12:51:38 +00:00
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
yield ("govuk", "GOV.UK")
|
2022-03-03 12:51:38 +00:00
|
|
|
|
|
|
|
|
if (
|
2023-07-12 12:09:44 -04:00
|
|
|
service.organization_type == Organization.TYPE_FEDERAL
|
|
|
|
|
and service.organization
|
|
|
|
|
and organization_branding_id is None # don't offer both if org has default
|
2023-08-25 09:12:23 -07:00
|
|
|
and service.email_branding_name.lower()
|
|
|
|
|
!= f"GOV.UK and {service.organization.name}".lower()
|
2022-03-03 12:51:38 +00:00
|
|
|
):
|
2023-08-25 09:12:23 -07:00
|
|
|
yield ("govuk_and_org", f"GOV.UK and {service.organization.name}")
|