Storing more info about an organisation

Currently we have
- a thing in the database called an ‘organisation’ which we don’t use
- the idea of an organisation which we derive from the user’s email
  address and is used to set the default branding for their service and
  determine whether they’ve signed the MOU

We should make these two things into one thing, by storing everything
we know about an organisation against that organisation in the database.
This will be much less laborious than storing it in a YAML file that
needs a deploy every time it’s updated.

An organisation can now have:
- domains which we can use to automatically associate services with it
  (eg anyone whose email address ends in `dwp.gsi.gov.uk` gets services
  they create associated to the DWP organisation)
- default letter branding for any new services
- default email branding for any new services
This commit is contained in:
Chris Hill-Scott
2019-02-19 11:47:30 +00:00
parent 46abcfd96d
commit d7e03e00d3
5 changed files with 221 additions and 13 deletions

View File

@@ -1,3 +1,4 @@
import datetime
import uuid
import pytest
@@ -16,7 +17,13 @@ from app.dao.organisation_dao import (
)
from app.models import Organisation
from tests.app.db import create_organisation, create_service, create_user
from tests.app.db import (
create_email_branding,
create_letter_branding,
create_organisation,
create_service,
create_user,
)
def test_get_organisations_gets_all_organisations_alphabetically_with_active_organisations_first(
@@ -47,19 +54,38 @@ def test_get_organisation_by_id_gets_correct_organisation(notify_db, notify_db_s
assert organisation_from_db == organisation
def test_update_organisation(notify_db, notify_db_session):
updated_name = 'new name'
def test_update_organisation(
notify_db,
notify_db_session,
):
create_organisation()
organisation = Organisation.query.one()
user = create_user()
email_branding = create_email_branding()
letter_branding = create_letter_branding()
assert organisation.name != updated_name
data = {
'name': 'new name',
"crown": True,
"organisation_type": 'local',
"agreement_signed": True,
"agreement_signed_at": datetime.datetime.utcnow(),
"agreement_signed_by_id": user.id,
"agreement_signed_version": 999.99,
"letter_branding_id": letter_branding.id,
"email_branding_id": email_branding.id,
}
dao_update_organisation(organisation.id, **{'name': updated_name})
for attribute, value in data.items():
assert getattr(organisation, attribute) != value
dao_update_organisation(organisation.id, **data)
organisation = Organisation.query.one()
assert organisation.name == updated_name
for attribute, value in data.items():
assert getattr(organisation, attribute) == value
def test_add_service_to_organisation(notify_db, notify_db_session, sample_service, sample_organisation):