From 9ecb666290ef3f082365bbaff05a7f206b88476b Mon Sep 17 00:00:00 2001 From: chrisw Date: Thu, 14 Sep 2017 16:26:46 +0100 Subject: [PATCH] Fixed bug where a user with an organisation that wanted the GOVUK only branding ended up with both If a user was to have an organisation selected in the email settings within the platform admin section, they would be sending emails that contained both the organisation's branding and GOV.UK's. Fix adds a check to ensure that the branding dictionary does not contain organisation details if the the service branding settings is set to 'gov' --- app/delivery/send_to_providers.py | 15 +++++++++++---- tests/app/delivery/test_send_to_providers.py | 13 +++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index c9aa84a20..9aafe1a35 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -15,9 +15,16 @@ from app.dao.provider_details_dao import ( ) from app.celery.research_mode_tasks import send_sms_response, send_email_response from app.dao.templates_dao import dao_get_template_by_id -from app.models import SMS_TYPE, KEY_TYPE_TEST, BRANDING_ORG, EMAIL_TYPE, NOTIFICATION_TECHNICAL_FAILURE, \ - NOTIFICATION_SENT, NOTIFICATION_SENDING - +from app.models import ( + SMS_TYPE, + KEY_TYPE_TEST, + BRANDING_ORG, + BRANDING_GOVUK, + EMAIL_TYPE, + NOTIFICATION_TECHNICAL_FAILURE, + NOTIFICATION_SENT, + NOTIFICATION_SENDING +) from app.celery.statistics_tasks import create_initial_notification_statistic_tasks @@ -168,7 +175,7 @@ def get_logo_url(base_url, logo_file): def get_html_email_options(service): govuk_banner = service.branding != BRANDING_ORG - if service.organisation: + if service.organisation and service.branding != BRANDING_GOVUK: logo_url = get_logo_url( current_app.config['ADMIN_BASE_URL'], service.organisation.logo diff --git a/tests/app/delivery/test_send_to_providers.py b/tests/app/delivery/test_send_to_providers.py index 35368becf..5be786361 100644 --- a/tests/app/delivery/test_send_to_providers.py +++ b/tests/app/delivery/test_send_to_providers.py @@ -19,6 +19,7 @@ from app.models import ( KEY_TYPE_TEST, KEY_TYPE_TEAM, BRANDING_ORG, + BRANDING_GOVUK, BRANDING_BOTH) from tests.app.db import create_service, create_template, create_notification, create_inbound_number @@ -426,6 +427,18 @@ def test_get_html_email_renderer_with_branding_details(branding_type, govuk_bann assert options['brand_name'] == 'Justice League' +def test_get_html_email_renderer_with_branding_details_and_render_govuk_banner_only(notify_db, sample_service): + sample_service.branding = BRANDING_GOVUK + org = Organisation(colour='#000000', logo='justice-league.png', name='Justice League') + sample_service.organisation = org + notify_db.session.add_all([sample_service, org]) + notify_db.session.commit() + + options = send_to_providers.get_html_email_options(sample_service) + + assert options == {'govuk_banner': True} + + def test_get_html_email_renderer_prepends_logo_path(notify_api): Service = namedtuple('Service', ['branding', 'organisation']) Organisation = namedtuple('Organisation', ['colour', 'name', 'logo'])