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.
This commit is contained in:
Rebecca Law
2018-11-05 10:54:42 +00:00
committed by Rebecca Law
parent 39198ed67e
commit 4849ecdf63
4 changed files with 71 additions and 7 deletions

View File

@@ -885,7 +885,7 @@ class Template(TemplateBase):
)
@classmethod
def from_json(cls, data):
def from_json(cls, data, folder):
"""
Assumption: data has been validated appropriately.
@@ -895,7 +895,8 @@ class Template(TemplateBase):
fields['created_by_id'] = fields.pop('created_by')
fields['service_id'] = fields.pop('service')
if fields.pop("parent_folder_id"):
fields['folder'] = folder
return cls(**fields)