mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Using jsonschema for create_template.
Updated jsonschema to Draft7, this allowed a conditional validation on subject, if template_type == 'email' or 'letter' then subject is required. This version is backward compatible with Draft4. When creating TempalteRedacted, I've built the dict depending on if the created_by or created_by_id exists.
This commit is contained in:
@@ -21,11 +21,16 @@ def dao_create_template(template):
|
||||
template.id = uuid.uuid4() # must be set now so version history model can use same id
|
||||
template.archived = False
|
||||
|
||||
template.template_redacted = TemplateRedacted(
|
||||
template=template,
|
||||
redact_personalisation=False,
|
||||
updated_by=template.created_by
|
||||
)
|
||||
redacted_dict = {
|
||||
"template": template,
|
||||
"redact_personalisation": False,
|
||||
}
|
||||
if template.created_by:
|
||||
redacted_dict.update({"updated_by": template.created_by})
|
||||
else:
|
||||
redacted_dict.update({"updated_by_id": template.created_by_id})
|
||||
|
||||
template.template_redacted = TemplateRedacted(**redacted_dict)
|
||||
|
||||
db.session.add(template)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user