mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 05:29:38 -04:00
Hide current folder templates if user doesn't have a folder permission
TemplateList gets a list of templates in a current folder separately, so we need to make sure `service.get_templates` checks for the appropriate user permission
This commit is contained in:
committed by
Pea Tyczynska
parent
70e6732255
commit
3d401ce856
@@ -154,7 +154,12 @@ class Service():
|
||||
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):
|
||||
def get_templates(self, template_type='all', template_folder_id=None, user_id=None):
|
||||
if user_id and template_folder_id and self.has_permission('edit_folder_permissions'):
|
||||
folder = self.get_template_folder(template_folder_id)
|
||||
if user_id not in folder.get("users_with_permission", []):
|
||||
return []
|
||||
|
||||
if isinstance(template_type, str):
|
||||
template_type = [template_type]
|
||||
if template_folder_id:
|
||||
|
||||
@@ -40,7 +40,7 @@ class TemplateList():
|
||||
yield sub_item
|
||||
|
||||
for item in self.service.get_templates(
|
||||
template_type, template_folder_id
|
||||
template_type, template_folder_id, user_id
|
||||
):
|
||||
yield TemplateListTemplate(
|
||||
item,
|
||||
|
||||
Reference in New Issue
Block a user