mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-02 17:48:36 -04:00
The NHS is a special case because it’s not one organisation, but it does have one consistent brand. So anyone working for an NHS organisation should have their default branding set when they create a service, even if we know nothing about their specific organisation.
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
from app import db
|
|
from app.dao.dao_utils import transactional
|
|
from app.models import LetterBranding
|
|
|
|
|
|
def dao_get_letter_branding_by_id(letter_branding_id):
|
|
return LetterBranding.query.filter(LetterBranding.id == letter_branding_id).one()
|
|
|
|
|
|
def dao_get_letter_branding_by_name(letter_branding_name):
|
|
return LetterBranding.query.filter_by(name=letter_branding_name).first()
|
|
|
|
|
|
def dao_get_letter_branding_by_domain(domain):
|
|
if not domain:
|
|
return None
|
|
return LetterBranding.query.filter(
|
|
LetterBranding.domain == domain
|
|
).first()
|
|
|
|
|
|
def dao_get_all_letter_branding():
|
|
return LetterBranding.query.order_by(LetterBranding.name).all()
|
|
|
|
|
|
@transactional
|
|
def dao_create_letter_branding(letter_branding):
|
|
db.session.add(letter_branding)
|
|
|
|
|
|
@transactional
|
|
def dao_update_letter_branding(letter_branding_id, **kwargs):
|
|
letter_branding = LetterBranding.query.get(letter_branding_id)
|
|
for key, value in kwargs.items():
|
|
setattr(letter_branding, key, value or None)
|
|
db.session.add(letter_branding)
|
|
return letter_branding
|