mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-12 13:20:43 -04:00
Add model properties for template and folder IDs
We’re going to need a way to find out if, for a given ID: 1. its a template or a folder 2. if it belongs to a given service To do 2., we can make a set of all the IDs, to see if a given ID is a member of that set. To do 1. we can make two sets, one for templates and one for folders. The natural home for these sets is on the service model.
This commit is contained in:
@@ -100,6 +100,10 @@ class Service():
|
||||
if template['template_type'] in self.available_template_types
|
||||
]
|
||||
|
||||
@cached_property
|
||||
def all_template_ids(self):
|
||||
return {template['id'] for template in self.all_templates}
|
||||
|
||||
def get_templates(self, template_type='all', template_folder_id=None):
|
||||
if isinstance(template_type, str):
|
||||
template_type = [template_type]
|
||||
@@ -284,6 +288,10 @@ class Service():
|
||||
def all_template_folders(self):
|
||||
return template_folder_api_client.get_template_folders(self.id)
|
||||
|
||||
@cached_property
|
||||
def all_template_folder_ids(self):
|
||||
return {folder['id'] for folder in self.all_template_folders}
|
||||
|
||||
def get_template_folders(self, parent_folder_id=None):
|
||||
return [
|
||||
folder for folder in self.all_template_folders
|
||||
|
||||
Reference in New Issue
Block a user