Return all templates for the user if the folder permissions flag is off

Putting the permission check in the get_user_template_folders allows
us to replace `all_template_folders` usage with the new method without
having to worry about the temporary service permission flag.
This commit is contained in:
Alexey Bezhan
2019-03-06 14:54:53 +00:00
committed by Pea Tyczynska
parent de237e9e6f
commit 1fb7a2515f
2 changed files with 5 additions and 0 deletions

View File

@@ -380,6 +380,9 @@ class Service():
return {folder['id'] for folder in self.all_template_folders}
def get_user_template_folders(self, user_id):
if not self.has_permission("edit_folder_permissions"):
return self.all_template_folders
user_folders = []
for folder in self.all_template_folders:
if user_id not in folder.get("users_with_permission", []):