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:
Chris Hill-Scott
2018-11-08 14:46:18 +00:00
parent 980d66bdaa
commit cdb5b47c4d
10 changed files with 322 additions and 25 deletions

View File

@@ -331,3 +331,14 @@ class Service():
self.get_templates(template_type, template_folder_id) +
self.get_template_folders(template_folder_id)
)
def move_to_folder(self, ids_to_move, move_to):
ids_to_move = set(ids_to_move)
template_folder_api_client.move_to_folder(
service_id=self.id,
folder_id=move_to,
template_ids=ids_to_move & self.all_template_ids,
folder_ids=ids_to_move & self.all_template_folder_ids,
)