Removed database calls and made scope filter a callable

This commit is contained in:
0mar
2021-02-25 07:30:41 +01:00
parent de2e8ff355
commit 1c789fcbb5
5 changed files with 128 additions and 80 deletions

View File

@@ -38,10 +38,8 @@ class GroupListAPIHandler(_GroupAPIHandler):
def get(self):
"""List groups"""
groups = self.db.query(orm.Group)
scope_filter = self.get_scope_filter(self.db)
if scope_filter is not None:
groups = groups.filter(orm.Group.name.in_(scope_filter))
data = [self.group_model(g) for g in groups]
scope_filter = self.get_scope_filter('read:groups')
data = [self.group_model(g) for g in groups if scope_filter(g)]
self.write(json.dumps(data))
@needs_scope('admin:groups')