From ad0ffcc3f36356850b0f540f41723c3919fb5836 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Thu, 30 Aug 2018 11:38:47 +0100 Subject: [PATCH] Fix issue that happens with branding_style of None Setting the branding_style to 'None' causes the API to remove the email_branding field from a service model. The branding request page controller was depending on that value being to present get the brand type. The email preview page (used in an iframe on various pages) wasn't able to recognise a branding_style of 'None', causing a blank page to render. --- app/main/views/index.py | 4 ++-- app/main/views/service_settings.py | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/main/views/index.py b/app/main/views/index.py index 685cb77f9..5e91a7982 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -81,9 +81,9 @@ def design_content(): @main.route('/_email') def email_template(): branding_type = 'govuk' - branding_style = request.args.get('branding_style', None) + branding_style = request.args.get('branding_style', 'None') - if branding_style: + if branding_style != 'None': email_branding = email_branding_client.get_email_branding(branding_style)['email_branding'] branding_type = email_branding['brand_type'] diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index b774f03fc..c3046abbe 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -971,11 +971,15 @@ def link_service_to_organisation(service_id): @user_has_permissions('manage_service') def branding_request(service_id): - email_branding = email_branding_client.get_email_branding( - current_service.email_branding)['email_branding'] + branding_type = 'govuk' + + if current_service.email_branding: + email_branding = email_branding_client.get_email_branding( + current_service.email_branding)['email_branding'] + branding_type = email_branding['brand_type'] form = BrandingOptionsEmail( - options=email_branding['brand_type'] + options=branding_type ) if form.validate_on_submit():