mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
Explain the workings of get_user_template_folders
This commit is contained in:
@@ -385,6 +385,19 @@ class Service():
|
|||||||
return {folder['id'] for folder in self.all_template_folders}
|
return {folder['id'] for folder in self.all_template_folders}
|
||||||
|
|
||||||
def get_user_template_folders(self, user_id):
|
def get_user_template_folders(self, user_id):
|
||||||
|
"""Returns a modified list of folders a user has permission to view
|
||||||
|
|
||||||
|
For each folder, we do the following:
|
||||||
|
- if user has no permission to view the folder, skip it
|
||||||
|
- if folder is visible and its parent is visible, we add it to the list of folders
|
||||||
|
we later return without modifying anything
|
||||||
|
- if folder is visible, but the parent is not, we iterate through the parent until we
|
||||||
|
either find a visible parent or reach root folder. On each iteration we concatenate
|
||||||
|
invisible parent folder name to the front of our folder name, modifying the name, and we
|
||||||
|
change parent_folder_id attribute to a higher level parent. This flattens the path to the
|
||||||
|
folder making sure it displays in the closest visible parent.
|
||||||
|
|
||||||
|
"""
|
||||||
if not self.has_permission("edit_folder_permissions"):
|
if not self.has_permission("edit_folder_permissions"):
|
||||||
return self.all_template_folders
|
return self.all_template_folders
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user