mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
attempt to pull logos from the admin app's static images directory
(this is configured by a config value)
This commit is contained in:
@@ -1,27 +1,27 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from monotonic import monotonic
|
from monotonic import monotonic
|
||||||
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
from flask import current_app
|
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 import notify_celery, statsd_client, clients, create_uuid
|
||||||
from app.clients.email import EmailClientException
|
from app.clients.email import EmailClientException
|
||||||
from app.clients.sms import SmsClientException
|
from app.clients.sms import SmsClientException
|
||||||
|
|
||||||
from app.dao.notifications_dao import (
|
from app.dao.notifications_dao import (
|
||||||
update_provider_stats,
|
update_provider_stats,
|
||||||
get_notification_by_id,
|
get_notification_by_id,
|
||||||
dao_update_notification,
|
dao_update_notification,
|
||||||
update_notification_status_by_id
|
update_notification_status_by_id
|
||||||
)
|
)
|
||||||
|
|
||||||
from app.dao.provider_details_dao import get_provider_details_by_notification_type
|
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.dao.services_dao import dao_fetch_service_by_id
|
||||||
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 notifications_utils.recipients import (
|
|
||||||
validate_and_format_phone_number
|
|
||||||
)
|
|
||||||
|
|
||||||
from app.dao.templates_dao import dao_get_template_by_id
|
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.models import SMS_TYPE, EMAIL_TYPE, KEY_TYPE_TEST, BRANDING_ORG
|
||||||
from app.statsd_decorators import statsd
|
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):
|
def get_html_email_renderer(service):
|
||||||
govuk_banner = service.branding != BRANDING_ORG
|
govuk_banner = service.branding != BRANDING_ORG
|
||||||
if service.organisation:
|
if service.organisation:
|
||||||
|
logo = '{}{}{}'.format(
|
||||||
|
current_app.config['ADMIN_BASE_URL'],
|
||||||
|
current_app.config['BRANDING_PATH'],
|
||||||
|
service.organisation.logo
|
||||||
|
)
|
||||||
branding = {
|
branding = {
|
||||||
'brand_colour': service.organisation.colour,
|
'brand_colour': service.organisation.colour,
|
||||||
'brand_logo': service.organisation.logo,
|
'brand_logo': logo,
|
||||||
'brand_name': service.organisation.name,
|
'brand_name': service.organisation.name,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class Config(object):
|
|||||||
PAGE_SIZE = 50
|
PAGE_SIZE = 50
|
||||||
SMS_CHAR_COUNT_LIMIT = 495
|
SMS_CHAR_COUNT_LIMIT = 495
|
||||||
MMG_URL = os.environ['MMG_URL']
|
MMG_URL = os.environ['MMG_URL']
|
||||||
|
BRANDING_PATH = '/static/images/email-template/crests/'
|
||||||
|
|
||||||
NOTIFY_SERVICE_ID = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
|
NOTIFY_SERVICE_ID = 'd6aa2c68-a2d9-4437-ab19-3ae8eb202553'
|
||||||
INVITATION_EMAIL_TEMPLATE_ID = '4f46df42-f795-4cc4-83bb-65ca312f49cc'
|
INVITATION_EMAIL_TEMPLATE_ID = '4f46df42-f795-4cc4-83bb-65ca312f49cc'
|
||||||
|
|||||||
@@ -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):
|
def test_get_html_email_renderer_should_return_for_normal_service(sample_service):
|
||||||
renderer = provider_tasks.get_html_email_renderer(sample_service)
|
renderer = provider_tasks.get_html_email_renderer(sample_service)
|
||||||
assert renderer.govuk_banner == True
|
assert renderer.govuk_banner
|
||||||
assert renderer.brand_colour == None
|
assert renderer.brand_colour is None
|
||||||
assert renderer.brand_logo == None
|
assert renderer.brand_logo is None
|
||||||
assert renderer.brand_name == None
|
assert renderer.brand_name is None
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('branding_type, govuk_banner', [
|
@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)
|
renderer = provider_tasks.get_html_email_renderer(sample_service)
|
||||||
|
|
||||||
assert renderer.govuk_banner == govuk_banner
|
assert renderer.govuk_banner == govuk_banner
|
||||||
assert renderer.brand_colour == '#000000'
|
assert renderer.brand_colour == '000000'
|
||||||
assert renderer.brand_name == 'Justice League'
|
assert renderer.brand_name == 'Justice League'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(strict=True)
|
def test_get_html_email_renderer_prepends_logo_path(notify_db, sample_service):
|
||||||
def test_get_html_email_renderer_prepends_logo_path(branding_type, govuk_banner, notify_db, sample_service):
|
|
||||||
sample_service.branding = BRANDING_ORG
|
sample_service.branding = BRANDING_ORG
|
||||||
org = Organisation(colour='#000000', logo='justice-league.png', name='Justice League')
|
org = Organisation(colour='#000000', logo='justice-league.png', name='Justice League')
|
||||||
sample_service.organisation = org
|
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)
|
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):
|
def _get_provider_statistics(service, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user