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

@@ -2,6 +2,7 @@ from app import db
from app.dao.dao_utils import transactional
from app.models import (
Organisation,
Domain,
InvitedOrganisationUser,
User
)
@@ -34,10 +35,26 @@ def dao_create_organisation(organisation):
@transactional
def dao_update_organisation(organisation_id, **kwargs):
return Organisation.query.filter_by(id=organisation_id).update(
domains = kwargs.pop('domains', [])
organisation = Organisation.query.filter_by(id=organisation_id).update(
kwargs
)
if domains:
Domain.query.filter_by(organisation_id=organisation_id).delete()
db.session.bulk_save_objects([
Domain(domain=domain, organisation_id=organisation_id)
for domain in domains
])
db.session.commit()
return organisation
@transactional
def dao_add_service_to_organisation(service, organisation_id):