diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index 9aafe1a35..fe2d1fe76 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -19,6 +19,7 @@ from app.models import ( SMS_TYPE, KEY_TYPE_TEST, BRANDING_ORG, + BRANDING_ORG_BANNER, BRANDING_GOVUK, EMAIL_TYPE, NOTIFICATION_TECHNICAL_FAILURE, @@ -174,7 +175,8 @@ def get_logo_url(base_url, logo_file): def get_html_email_options(service): - govuk_banner = service.branding != BRANDING_ORG + govuk_banner = service.branding not in (BRANDING_ORG, BRANDING_ORG_BANNER) + brand_banner = service.branding == BRANDING_ORG_BANNER if service.organisation and service.branding != BRANDING_GOVUK: logo_url = get_logo_url( current_app.config['ADMIN_BASE_URL'], @@ -189,7 +191,7 @@ def get_html_email_options(service): else: branding = {} - return dict(govuk_banner=govuk_banner, **branding) + return dict(govuk_banner=govuk_banner, brand_banner=brand_banner, **branding) def technical_failure(notification): diff --git a/app/models.py b/app/models.py index 8d1437986..207e56e8c 100644 --- a/app/models.py +++ b/app/models.py @@ -123,6 +123,7 @@ user_to_service = db.Table( BRANDING_GOVUK = 'govuk' BRANDING_ORG = 'org' BRANDING_BOTH = 'both' +BRANDING_ORG_BANNER = 'org_banner' class BrandingTypes(db.Model): diff --git a/migrations/versions/0120_add_org_banner_branding.py b/migrations/versions/0120_add_org_banner_branding.py new file mode 100644 index 000000000..015b4e6f3 --- /dev/null +++ b/migrations/versions/0120_add_org_banner_branding.py @@ -0,0 +1,22 @@ +""" + +Revision ID: 0120_add_org_banner_branding +Revises: 0119_add_email_reply_to +Create Date: 2017-09-18 14:18:49.087143 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision = '0120_add_org_banner_branding' +down_revision = '0119_add_email_reply_to' + + +def upgrade(): + op.execute("INSERT INTO branding_type VALUES ('org_banner')") + +def downgrade(): + op.execute("UPDATE services SET branding = 'org' WHERE branding = 'org_banner'") + op.execute("DELETE FROM branding_type WHERE name = 'org_banner'") + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 573d446db..7d6fbf67a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,6 +25,6 @@ notifications-python-client==4.4.0 awscli>=1.11,<1.12 awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@21.2.0#egg=notifications-utils==21.2.0 +git+https://github.com/alphagov/notifications-utils.git@21.3.0#egg=notifications-utils==21.3.0 git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3 diff --git a/tests/app/delivery/test_send_to_providers.py b/tests/app/delivery/test_send_to_providers.py index 5be786361..cad34eb8d 100644 --- a/tests/app/delivery/test_send_to_providers.py +++ b/tests/app/delivery/test_send_to_providers.py @@ -20,7 +20,8 @@ from app.models import ( KEY_TYPE_TEAM, BRANDING_ORG, BRANDING_GOVUK, - BRANDING_BOTH) + BRANDING_BOTH, + BRANDING_ORG_BANNER) from tests.app.db import create_service, create_template, create_notification, create_inbound_number @@ -411,7 +412,8 @@ def test_get_html_email_renderer_should_return_for_normal_service(sample_service @pytest.mark.parametrize('branding_type, govuk_banner', [ (BRANDING_ORG, False), - (BRANDING_BOTH, True) + (BRANDING_BOTH, True), + (BRANDING_ORG_BANNER, False) ]) def test_get_html_email_renderer_with_branding_details(branding_type, govuk_banner, notify_db, sample_service): sample_service.branding = branding_type @@ -426,6 +428,11 @@ def test_get_html_email_renderer_with_branding_details(branding_type, govuk_bann assert options['brand_colour'] == '#000000' assert options['brand_name'] == 'Justice League' + if sample_service.branding == BRANDING_ORG_BANNER: + assert options['brand_banner'] is True + else: + assert options['brand_banner'] is False + def test_get_html_email_renderer_with_branding_details_and_render_govuk_banner_only(notify_db, sample_service): sample_service.branding = BRANDING_GOVUK @@ -436,7 +443,7 @@ def test_get_html_email_renderer_with_branding_details_and_render_govuk_banner_o options = send_to_providers.get_html_email_options(sample_service) - assert options == {'govuk_banner': True} + assert options == {'govuk_banner': True, 'brand_banner': False} def test_get_html_email_renderer_prepends_logo_path(notify_api):