Files
notifications-api/app/template/template_schemas.py
Rebecca Law 4849ecdf63 Update the template_schema to include a parent_folder_id.
When creating the Tempalte from_json, the folder is passed in. Since some validation should done, as in the folder exists and is for the same service, the folder is passed through to the Tempalte.from_json method.
When the template is persisted so is the relationship to folders.
TODO: If the folder is invalid a specific message should be returned.
2018-11-07 16:17:09 +00:00

30 lines
920 B
Python

from app.models import (
TEMPLATE_PROCESS_TYPE,
TEMPLATE_TYPES,
)
from app.schema_validation.definitions import uuid
post_create_template_schema = {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST create new template",
"type": "object",
"title": "payload for POST /service/<uuid:service_id>/template",
"properties": {
"name": {"type": "string"},
"template_type": {"enum": TEMPLATE_TYPES},
"service": uuid,
"process_type": {"emun": TEMPLATE_PROCESS_TYPE},
"content": {"type": "string"},
"subject": {"type": "string"},
"created_by": uuid,
"parent_folder_id": uuid
},
"if": {
"properties": {
"template_type": {"enum": ["email", "letter"]}
}
},
"then": {"required": ["subject"]},
"required": ["name", "template_type", "content", "service", "created_by"]
}