mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 00:41:35 -05:00
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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user