mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-10 03:14:58 -04:00
Post to the API when moving folders and templates
This commit adds logic to: - take the list of selected folders and templates - split it into two lists (of folders and templates) - `POST` that data to the API, to effect the movement of said folders and templates I’ve tried to architect it in such a way that we can easily add more template ‘operations’ in the future, as we add more forms to the choose template page.
This commit is contained in:
@@ -24,5 +24,24 @@ class TemplateFolderAPIClient(NotifyAdminAPIClient):
|
||||
def get_template_folders(self, service_id):
|
||||
return self.get('/service/{}/template-folder'.format(service_id))['template_folders']
|
||||
|
||||
@cache.delete('service-{service_id}-template-folders')
|
||||
@cache.delete('service-{service_id}-templates')
|
||||
def move_to_folder(self, service_id, folder_id, template_ids, folder_ids):
|
||||
|
||||
if folder_id:
|
||||
url = '/service/{}/template-folder/move-to-folder/{}'.format(service_id, folder_id)
|
||||
else:
|
||||
url = '/service/{}/template-folder/move-to-folder'.format(service_id)
|
||||
|
||||
self.post(url, {
|
||||
'templates': list(template_ids),
|
||||
'folders': list(folder_ids),
|
||||
})
|
||||
|
||||
self.redis_client.delete(*map(
|
||||
'template-{}-version-None'.format,
|
||||
template_ids,
|
||||
))
|
||||
|
||||
|
||||
template_folder_api_client = TemplateFolderAPIClient()
|
||||
|
||||
Reference in New Issue
Block a user