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'
This commit is contained in:
chrisw
2017-09-14 16:26:46 +01:00
parent b81b5bc03c
commit 9ecb666290
2 changed files with 24 additions and 4 deletions

View File

@@ -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.celery.research_mode_tasks import send_sms_response, send_email_response
from app.dao.templates_dao import dao_get_template_by_id 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, \ from app.models import (
NOTIFICATION_SENT, NOTIFICATION_SENDING 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 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): def get_html_email_options(service):
govuk_banner = service.branding != BRANDING_ORG govuk_banner = service.branding != BRANDING_ORG
if service.organisation: if service.organisation and service.branding != BRANDING_GOVUK:
logo_url = get_logo_url( logo_url = get_logo_url(
current_app.config['ADMIN_BASE_URL'], current_app.config['ADMIN_BASE_URL'],
service.organisation.logo service.organisation.logo

View File

@@ -19,6 +19,7 @@ from app.models import (
KEY_TYPE_TEST, KEY_TYPE_TEST,
KEY_TYPE_TEAM, KEY_TYPE_TEAM,
BRANDING_ORG, BRANDING_ORG,
BRANDING_GOVUK,
BRANDING_BOTH) BRANDING_BOTH)
from tests.app.db import create_service, create_template, create_notification, create_inbound_number 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' 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): def test_get_html_email_renderer_prepends_logo_path(notify_api):
Service = namedtuple('Service', ['branding', 'organisation']) Service = namedtuple('Service', ['branding', 'organisation'])
Organisation = namedtuple('Organisation', ['colour', 'name', 'logo']) Organisation = namedtuple('Organisation', ['colour', 'name', 'logo'])