mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-14 10:58:06 -04:00
When creating a new NHS org, set default email branding to NHS
This is more appropriate default for that org than gov.uk branding and will help us with our work to make setting the branding more self-service.
This commit is contained in:
@@ -185,6 +185,7 @@ class Config(object):
|
||||
MOU_SIGNED_ON_BEHALF_ON_BEHALF_RECEIPT_TEMPLATE_ID = '522b6657-5ca5-4368-a294-6b527703bd0b'
|
||||
NOTIFY_INTERNATIONAL_SMS_SENDER = '07984404008'
|
||||
LETTERS_VOLUME_EMAIL_TEMPLATE_ID = '11fad854-fd38-4a7c-bd17-805fb13dfc12'
|
||||
NHS_EMAIL_BRANDING_ID = 'a7dc4e56-660b-4db7-8cff-12c37b12b5ea'
|
||||
# we only need real email in Live environment (production)
|
||||
DVLA_EMAIL_ADDRESSES = json.loads(os.environ.get('DVLA_EMAIL_ADDRESSES', '[]'))
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ from app.dao.services_dao import dao_fetch_service_by_id
|
||||
from app.dao.templates_dao import dao_get_template_by_id
|
||||
from app.dao.users_dao import get_user_by_id
|
||||
from app.errors import InvalidRequest, register_errors
|
||||
from app.models import KEY_TYPE_NORMAL, Organisation
|
||||
from app.models import KEY_TYPE_NORMAL, NHS_ORGANISATION_TYPES, Organisation
|
||||
from app.notifications.process_notifications import (
|
||||
persist_notification,
|
||||
send_notification_to_queue,
|
||||
@@ -93,6 +93,9 @@ def create_organisation():
|
||||
|
||||
validate(data, post_create_organisation_schema)
|
||||
|
||||
if data["organisation_type"] in NHS_ORGANISATION_TYPES:
|
||||
data["email_branding_id"] = current_app.config['NHS_EMAIL_BRANDING_ID']
|
||||
|
||||
organisation = Organisation(**data)
|
||||
dao_create_organisation(organisation)
|
||||
return jsonify(organisation.serialize()), 201
|
||||
|
||||
@@ -502,13 +502,17 @@ def create_service_callback_api(
|
||||
return service_callback_api
|
||||
|
||||
|
||||
def create_email_branding(colour='blue', logo='test_x2.png', name='test_org_1', text='DisplayName'):
|
||||
def create_email_branding(
|
||||
id=None, colour='blue', logo='test_x2.png', name='test_org_1', text='DisplayName'
|
||||
):
|
||||
data = {
|
||||
'colour': colour,
|
||||
'logo': logo,
|
||||
'name': name,
|
||||
'text': text,
|
||||
}
|
||||
if id:
|
||||
data['id'] = id
|
||||
email_branding = EmailBranding(**data)
|
||||
dao_create_email_branding(email_branding)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import uuid
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
from flask import current_app
|
||||
from freezegun import freeze_time
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
@@ -187,6 +188,43 @@ def test_post_create_organisation(admin_request, notify_db_session, crown):
|
||||
assert len(organisation) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize('org_type', ["nhs_central", "nhs_local", "nhs_gp"])
|
||||
def test_post_create_organisation_sets_default_nhs_branding_for_nhs_orgs(
|
||||
admin_request, notify_db_session, org_type
|
||||
):
|
||||
# we wipe email_branding table in test db between the tests, so we have to recreate this branding
|
||||
# that is normally present on all environments and applied through migration
|
||||
nhs_email_branding_id = current_app.config['NHS_EMAIL_BRANDING_ID']
|
||||
create_email_branding(
|
||||
id=nhs_email_branding_id,
|
||||
logo='1ac6f483-3105-4c9e-9017-dd7fb2752c44-nhs-blue_x2.png',
|
||||
name='NHS'
|
||||
)
|
||||
|
||||
data = {
|
||||
'name': 'test organisation',
|
||||
'active': True,
|
||||
'crown': False,
|
||||
'organisation_type': org_type,
|
||||
}
|
||||
|
||||
response = admin_request.post(
|
||||
'organisation.create_organisation',
|
||||
_data=data,
|
||||
_expected_status=201
|
||||
)
|
||||
|
||||
organisations = Organisation.query.all()
|
||||
|
||||
assert data['name'] == response['name']
|
||||
assert data['active'] == response['active']
|
||||
assert data['crown'] == response['crown']
|
||||
assert data['organisation_type'] == response['organisation_type']
|
||||
|
||||
assert len(organisations) == 1
|
||||
assert organisations[0].email_branding_id == uuid.UUID(nhs_email_branding_id)
|
||||
|
||||
|
||||
def test_post_create_organisation_existing_name_raises_400(admin_request, sample_organisation):
|
||||
data = {
|
||||
'name': sample_organisation.name,
|
||||
|
||||
Reference in New Issue
Block a user