Added a method to decide which colour to send to the notifications-utils HTMLEmailTemplate to create the content.

This commit is contained in:
Rebecca Law
2018-08-22 12:59:06 +01:00
parent 0b0e551626
commit fd16d7060a
3 changed files with 52 additions and 9 deletions

View File

@@ -30,7 +30,8 @@ from app.models import (
NOTIFICATION_CREATED,
NOTIFICATION_TECHNICAL_FAILURE,
NOTIFICATION_SENT,
NOTIFICATION_SENDING
NOTIFICATION_SENDING,
BRANDING_BOTH
)
@@ -198,8 +199,10 @@ def get_html_email_options(service):
service.email_branding.logo
) if service.email_branding.logo else None
colour = _set_colour(service)
branding = {
'brand_colour': service.email_branding.colour,
'brand_colour': colour,
'brand_logo': logo_url,
'brand_name': service.email_branding.text,
}
@@ -209,6 +212,15 @@ def get_html_email_options(service):
return dict(govuk_banner=govuk_banner, brand_banner=brand_banner, **branding)
def _set_colour(service):
if service.branding in [BRANDING_BOTH, BRANDING_ORG]:
return service.email_branding.single_id_colour or service.email_branding.colour
elif service.branding == BRANDING_ORG_BANNER:
return service.email_branding.banner_colour or service.email_branding.colour
elif service.branding == BRANDING_GOVUK:
return None
def technical_failure(notification):
notification.status = NOTIFICATION_TECHNICAL_FAILURE
dao_update_notification(notification)