mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 05:58:53 -04:00
Update model and controller to handle parent_folder_id when creating a template.
If the parent_folder_id then check if the folder exists and is for the same service. If it is add the folder to the template model object, the relationship will be persisted when the template is saved. If the folder does not exist or is for a different service, then return a ResultNotFound error.
This commit is contained in:
@@ -888,15 +888,13 @@ class Template(TemplateBase):
|
||||
def from_json(cls, data, folder):
|
||||
"""
|
||||
Assumption: data has been validated appropriately.
|
||||
|
||||
Returns a Template object based on the provided data.
|
||||
"""
|
||||
fields = data.copy()
|
||||
|
||||
fields['created_by_id'] = fields.pop('created_by')
|
||||
fields['service_id'] = fields.pop('service')
|
||||
if fields.pop("parent_folder_id"):
|
||||
fields['folder'] = folder
|
||||
fields['folder'] = folder
|
||||
return cls(**fields)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user