mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Does two things:
1. Revert "Revert "Add unique constraint to email branding domain""
This reverts commit af9cb30ef3.
2. Don’t allow empty string in email branding domain
Columns with multiple `null`s can have a uniqueness constraint. Columns
with multiple empty string values are not considered unique.
This commit:
- removes any duplicate empty string values
- casts empty strings to null string any time these columns are updated
---
Squashed into this single commits because these two things are not
atomic as individual commits.
28 lines
731 B
Python
28 lines
731 B
Python
from app import db
|
|
from app.dao.dao_utils import transactional
|
|
from app.models import EmailBranding
|
|
|
|
|
|
def dao_get_email_branding_options():
|
|
return EmailBranding.query.all()
|
|
|
|
|
|
def dao_get_email_branding_by_id(email_branding_id):
|
|
return EmailBranding.query.filter_by(id=email_branding_id).one()
|
|
|
|
|
|
def dao_get_email_branding_by_name(email_branding_name):
|
|
return EmailBranding.query.filter_by(name=email_branding_name).one()
|
|
|
|
|
|
@transactional
|
|
def dao_create_email_branding(email_branding):
|
|
db.session.add(email_branding)
|
|
|
|
|
|
@transactional
|
|
def dao_update_email_branding(email_branding, **kwargs):
|
|
for key, value in kwargs.items():
|
|
setattr(email_branding, key, value or None)
|
|
db.session.add(email_branding)
|