mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 21:58:26 -04:00
Create a template in a folder.
This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user