Include list of users_with_permission in all folders response

This adds a list of user_ids of the users who have permission to view a folder
to the `get_template_folders_for_service` endpoint.
This commit is contained in:
Katie Smith
2019-02-22 13:26:20 +00:00
parent d981abf18e
commit 70cdcfff55
2 changed files with 34 additions and 4 deletions

View File

@@ -754,7 +754,8 @@ class TemplateFolder(db.Model):
'id': self.id,
'name': self.name,
'parent_id': self.parent_id,
'service_id': self.service_id
'service_id': self.service_id,
'users_with_permission': self.get_users_with_permission()
}
def is_parent_of(self, other):
@@ -764,6 +765,12 @@ class TemplateFolder(db.Model):
other = other.parent
return False
def get_users_with_permission(self):
service_users = self.users
users_with_permission = [str(service_user.user_id) for service_user in service_users]
return users_with_permission
template_folder_map = db.Table(
'template_folder_map',