diff --git a/app/celery/provider_tasks.py b/app/celery/provider_tasks.py index cb164b3ea..5fd215d8a 100644 --- a/app/celery/provider_tasks.py +++ b/app/celery/provider_tasks.py @@ -1,27 +1,27 @@ from datetime import datetime from monotonic import monotonic +from urllib.parse import urljoin + from flask import current_app +from notifications_utils.recipients import ( + validate_and_format_phone_number +) +from notifications_utils.template import Template, get_sms_fragment_count +from notifications_utils.renderers import HTMLEmail, PlainTextEmail, SMSMessage + from app import notify_celery, statsd_client, clients, create_uuid from app.clients.email import EmailClientException from app.clients.sms import SmsClientException - from app.dao.notifications_dao import ( update_provider_stats, get_notification_by_id, dao_update_notification, update_notification_status_by_id ) - from app.dao.provider_details_dao import get_provider_details_by_notification_type from app.dao.services_dao import dao_fetch_service_by_id from app.celery.research_mode_tasks import send_sms_response, send_email_response -from notifications_utils.recipients import ( - validate_and_format_phone_number -) - from app.dao.templates_dao import dao_get_template_by_id -from notifications_utils.template import Template, get_sms_fragment_count -from notifications_utils.renderers import HTMLEmail, PlainTextEmail, SMSMessage from app.models import SMS_TYPE, EMAIL_TYPE, KEY_TYPE_TEST, BRANDING_ORG from app.statsd_decorators import statsd @@ -190,9 +190,14 @@ def send_email_to_provider(self, service_id, notification_id): def get_html_email_renderer(service): govuk_banner = service.branding != BRANDING_ORG if service.organisation: + logo = '{}{}{}'.format( + current_app.config['ADMIN_BASE_URL'], + current_app.config['BRANDING_PATH'], + service.organisation.logo + ) branding = { 'brand_colour': service.organisation.colour, - 'brand_logo': service.organisation.logo, + 'brand_logo': logo, 'brand_name': service.organisation.name, } else: diff --git a/config.py b/config.py index 3ae8441c7..14610f079 100644 --- a/config.py +++ b/config.py @@ -28,6 +28,7 @@ class Config(object): PAGE_SIZE = 50 SMS_CHAR_COUNT_LIMIT = 495 MMG_URL = os.environ['MMG_URL'] + BRANDING_PATH = '/static/images/email-template/crests/' NOTIFY_SERVICE_ID = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553' INVITATION_EMAIL_TEMPLATE_ID = '4f46df42-f795-4cc4-83bb-65ca312f49cc' diff --git a/tests/app/celery/test_provider_tasks.py b/tests/app/celery/test_provider_tasks.py index ae5146129..11d0839cd 100644 --- a/tests/app/celery/test_provider_tasks.py +++ b/tests/app/celery/test_provider_tasks.py @@ -514,10 +514,10 @@ def test_should_not_set_billable_units_if_research_mode(notify_db, sample_servic def test_get_html_email_renderer_should_return_for_normal_service(sample_service): renderer = provider_tasks.get_html_email_renderer(sample_service) - assert renderer.govuk_banner == True - assert renderer.brand_colour == None - assert renderer.brand_logo == None - assert renderer.brand_name == None + assert renderer.govuk_banner + assert renderer.brand_colour is None + assert renderer.brand_logo is None + assert renderer.brand_name is None @pytest.mark.parametrize('branding_type, govuk_banner', [ @@ -534,12 +534,11 @@ def test_get_html_email_renderer_with_branding_details(branding_type, govuk_bann renderer = provider_tasks.get_html_email_renderer(sample_service) assert renderer.govuk_banner == govuk_banner - assert renderer.brand_colour == '#000000' + assert renderer.brand_colour == '000000' assert renderer.brand_name == 'Justice League' -@pytest.mark.xfail(strict=True) -def test_get_html_email_renderer_prepends_logo_path(branding_type, govuk_banner, notify_db, sample_service): +def test_get_html_email_renderer_prepends_logo_path(notify_db, sample_service): sample_service.branding = BRANDING_ORG org = Organisation(colour='#000000', logo='justice-league.png', name='Justice League') sample_service.organisation = org @@ -548,7 +547,7 @@ def test_get_html_email_renderer_prepends_logo_path(branding_type, govuk_banner, renderer = provider_tasks.get_html_email_renderer(sample_service) - assert renderer.brand_logo == 'https://localhost:6062/test/assets/images/justice-league.png' + assert renderer.brand_logo == 'http://localhost:6012/static/images/email-template/crests/justice-league.png' def _get_provider_statistics(service, **kwargs):