mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-17 07:20:55 -04:00
Merge pull request #1262 from gov-cjwaszczuk/master
Add a non-GOV.UK banner option for email branding
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
22
migrations/versions/0120_add_org_banner_branding.py
Normal file
22
migrations/versions/0120_add_org_banner_branding.py
Normal file
@@ -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'")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user