Create a template in a folder.

This commit is contained in:
Rebecca Law
2018-11-08 15:53:33 +00:00
parent 622fdfedc9
commit 146c7915b2
6 changed files with 60 additions and 9 deletions

View File

@@ -218,6 +218,7 @@ def add_template_by_type(service_id, template_folder_id=None):
service_id,
'Main heading',
'normal',
template_folder_id
)
return redirect(url_for(
'.view_template',
@@ -351,7 +352,8 @@ def add_service_template(service_id, template_type, template_folder_id=None):
form.template_content.data,
service_id,
form.subject.data if hasattr(form, 'subject') else None,
form.process_type.data
form.process_type.data,
template_folder_id
)
except HTTPError as e:
if (

View File

@@ -103,11 +103,10 @@ class Service():
def get_templates(self, template_type='all', template_folder_id=None):
if isinstance(template_type, str):
template_type = [template_type]
return [
template for template in self.all_templates
if (set(template_type) & {'all', template['template_type']})
and template.get('folder_id') == template_folder_id
and template.get('folder') == template_folder_id
]
@property

View File

@@ -126,7 +126,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
return self.delete(endpoint, data)
@cache.delete('service-{service_id}-templates')
def create_service_template(self, name, type_, content, service_id, subject=None, process_type='normal'):
def create_service_template(self, name, type_, content, service_id, subject=None, process_type='normal',
parent_folder_id=None):
"""
Create a service template.
"""
@@ -135,12 +136,16 @@ class ServiceAPIClient(NotifyAdminAPIClient):
"template_type": type_,
"content": content,
"service": service_id,
"process_type": process_type
"process_type": process_type,
}
if subject:
data.update({
'subject': subject
})
if parent_folder_id:
data.update({
'parent_folder_id': parent_folder_id
})
data = _attach_current_user(data)
endpoint = "/service/{0}/template".format(service_id)
return self.post(endpoint, data)