mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-08 21:33:13 -04:00
Remove govuk from possible brands
‘GOV.UK’ doesn’t make sense as a type of brand. It only made sense as a type of branding that a service had. Since we’ve: - deprecated the service branding column - made sure it’s not used as a value in the email branding table we can remove this value from the table of possible brand types.
This commit is contained in:
@@ -25,7 +25,6 @@ from app.models import (
|
|||||||
KEY_TYPE_TEST,
|
KEY_TYPE_TEST,
|
||||||
BRANDING_BOTH,
|
BRANDING_BOTH,
|
||||||
BRANDING_ORG_BANNER,
|
BRANDING_ORG_BANNER,
|
||||||
BRANDING_GOVUK,
|
|
||||||
EMAIL_TYPE,
|
EMAIL_TYPE,
|
||||||
NOTIFICATION_CREATED,
|
NOTIFICATION_CREATED,
|
||||||
NOTIFICATION_TECHNICAL_FAILURE,
|
NOTIFICATION_TECHNICAL_FAILURE,
|
||||||
@@ -190,10 +189,7 @@ def get_logo_url(base_url, logo_file):
|
|||||||
|
|
||||||
def get_html_email_options(service):
|
def get_html_email_options(service):
|
||||||
|
|
||||||
if (
|
if service.email_branding is None:
|
||||||
service.email_branding is None or
|
|
||||||
service.email_branding.brand_type == BRANDING_GOVUK
|
|
||||||
):
|
|
||||||
return {
|
return {
|
||||||
'govuk_banner': True,
|
'govuk_banner': True,
|
||||||
'brand_banner': False,
|
'brand_banner': False,
|
||||||
|
|||||||
@@ -188,11 +188,11 @@ user_to_organisation = db.Table(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
BRANDING_GOVUK = 'govuk'
|
BRANDING_GOVUK = 'govuk' # Deprecated outside migrations
|
||||||
BRANDING_ORG = 'org'
|
BRANDING_ORG = 'org'
|
||||||
BRANDING_BOTH = 'both'
|
BRANDING_BOTH = 'both'
|
||||||
BRANDING_ORG_BANNER = 'org_banner'
|
BRANDING_ORG_BANNER = 'org_banner'
|
||||||
BRANDING_TYPES = [BRANDING_GOVUK, BRANDING_ORG, BRANDING_BOTH, BRANDING_ORG_BANNER]
|
BRANDING_TYPES = [BRANDING_ORG, BRANDING_BOTH, BRANDING_ORG_BANNER]
|
||||||
|
|
||||||
|
|
||||||
class BrandingTypes(db.Model):
|
class BrandingTypes(db.Model):
|
||||||
@@ -213,7 +213,7 @@ class EmailBranding(db.Model):
|
|||||||
db.ForeignKey('branding_type.name'),
|
db.ForeignKey('branding_type.name'),
|
||||||
index=True,
|
index=True,
|
||||||
nullable=True,
|
nullable=True,
|
||||||
default=BRANDING_GOVUK
|
default=BRANDING_ORG
|
||||||
)
|
)
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Revises: 0220_email_brand_type_non_null
|
|||||||
Create Date: 2018-08-24 13:36:49.346156
|
Create Date: 2018-08-24 13:36:49.346156
|
||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
from app.models import BRANDING_ORG, BRANDING_GOVUK
|
||||||
|
|
||||||
|
|
||||||
revision = '0221_nullable_service_branding'
|
revision = '0221_nullable_service_branding'
|
||||||
@@ -20,6 +21,22 @@ def upgrade():
|
|||||||
op.alter_column('services_history', 'branding', nullable=True)
|
op.alter_column('services_history', 'branding', nullable=True)
|
||||||
op.alter_column('services', 'branding', nullable=True)
|
op.alter_column('services', 'branding', nullable=True)
|
||||||
|
|
||||||
|
op.execute("""
|
||||||
|
update
|
||||||
|
email_branding
|
||||||
|
set
|
||||||
|
brand_type = '{}'
|
||||||
|
where
|
||||||
|
brand_type = '{}'
|
||||||
|
""".format(BRANDING_ORG, BRANDING_GOVUK))
|
||||||
|
|
||||||
|
op.execute("""
|
||||||
|
delete from
|
||||||
|
branding_type
|
||||||
|
where
|
||||||
|
name = '{}'
|
||||||
|
""".format(BRANDING_GOVUK))
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
def downgrade():
|
||||||
|
|
||||||
@@ -30,3 +47,11 @@ def downgrade():
|
|||||||
|
|
||||||
op.alter_column('services', 'branding', nullable=False)
|
op.alter_column('services', 'branding', nullable=False)
|
||||||
op.alter_column('services_history', 'branding', nullable=False)
|
op.alter_column('services_history', 'branding', nullable=False)
|
||||||
|
|
||||||
|
op.execute("""
|
||||||
|
insert into
|
||||||
|
branding_type
|
||||||
|
(name)
|
||||||
|
values
|
||||||
|
('{}')
|
||||||
|
""".format(BRANDING_GOVUK))
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ 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,
|
||||||
BRANDING_ORG_BANNER
|
BRANDING_ORG_BANNER
|
||||||
)
|
)
|
||||||
@@ -202,7 +201,6 @@ def test_send_sms_should_use_template_version_from_notification_not_latest(
|
|||||||
def test_should_call_send_sms_response_task_if_research_mode(
|
def test_should_call_send_sms_response_task_if_research_mode(
|
||||||
notify_db, sample_service, sample_notification, mocker, research_mode, key_type
|
notify_db, sample_service, sample_notification, mocker, research_mode, key_type
|
||||||
):
|
):
|
||||||
sample_service.branding = BRANDING_GOVUK
|
|
||||||
mocker.patch('app.mmg_client.send_sms')
|
mocker.patch('app.mmg_client.send_sms')
|
||||||
mocker.patch('app.delivery.send_to_providers.send_sms_response')
|
mocker.patch('app.delivery.send_to_providers.send_sms_response')
|
||||||
|
|
||||||
@@ -446,15 +444,8 @@ def test_get_html_email_renderer_with_branding_details(branding_type, govuk_bann
|
|||||||
|
|
||||||
|
|
||||||
def test_get_html_email_renderer_with_branding_details_and_render_govuk_banner_only(notify_db, sample_service):
|
def test_get_html_email_renderer_with_branding_details_and_render_govuk_banner_only(notify_db, sample_service):
|
||||||
email_branding = EmailBranding(
|
sample_service.email_branding = None
|
||||||
brand_type=BRANDING_GOVUK,
|
notify_db.session.add_all([sample_service])
|
||||||
colour='#000000',
|
|
||||||
logo='justice-league.png',
|
|
||||||
name='Justice League',
|
|
||||||
text='League of Justice',
|
|
||||||
)
|
|
||||||
sample_service.email_branding = email_branding
|
|
||||||
notify_db.session.add_all([sample_service, email_branding])
|
|
||||||
notify_db.session.commit()
|
notify_db.session.commit()
|
||||||
|
|
||||||
options = send_to_providers.get_html_email_options(sample_service)
|
options = send_to_providers.get_html_email_options(sample_service)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from app.models import EmailBranding, BRANDING_GOVUK, BRANDING_ORG
|
from app.models import EmailBranding, BRANDING_ORG
|
||||||
from tests.app.db import create_email_branding
|
from tests.app.db import create_email_branding
|
||||||
|
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ def test_post_create_email_branding_without_brand_type_defaults(admin_request, n
|
|||||||
_data=data,
|
_data=data,
|
||||||
_expected_status=201
|
_expected_status=201
|
||||||
)
|
)
|
||||||
assert BRANDING_GOVUK == response['data']['brand_type']
|
assert BRANDING_ORG == response['data']['brand_type']
|
||||||
|
|
||||||
|
|
||||||
def test_post_create_email_branding_without_logo_is_ok(admin_request, notify_db_session):
|
def test_post_create_email_branding_without_logo_is_ok(admin_request, notify_db_session):
|
||||||
@@ -240,7 +240,7 @@ def test_create_email_branding_reject_invalid_brand_type(admin_request):
|
|||||||
_expected_status=400
|
_expected_status=400
|
||||||
)
|
)
|
||||||
|
|
||||||
assert response['errors'][0]['message'] == 'brand_type NOT A TYPE is not one of [govuk, org, both, org_banner]'
|
assert response['errors'][0]['message'] == 'brand_type NOT A TYPE is not one of [org, both, org_banner]'
|
||||||
|
|
||||||
|
|
||||||
def test_update_email_branding_reject_invalid_brand_type(admin_request, notify_db_session):
|
def test_update_email_branding_reject_invalid_brand_type(admin_request, notify_db_session):
|
||||||
@@ -256,4 +256,4 @@ def test_update_email_branding_reject_invalid_brand_type(admin_request, notify_d
|
|||||||
email_branding_id=email_branding.id
|
email_branding_id=email_branding.id
|
||||||
)
|
)
|
||||||
|
|
||||||
assert response['errors'][0]['message'] == 'brand_type NOT A TYPE is not one of [govuk, org, both, org_banner]'
|
assert response['errors'][0]['message'] == 'brand_type NOT A TYPE is not one of [org, both, org_banner]'
|
||||||
|
|||||||
Reference in New Issue
Block a user