##// END OF EJS Templates
auth-user: use new permissions helpers instead of defining the read list over and over.
marcink -
r4154:b5c053a4 default
parent child Browse files
Show More
@@ -1053,6 +1053,7 b' class AuthUser(object):'
1053 GLOBAL_PERMS = [x[0] for x in Permission.PERMS]
1053 GLOBAL_PERMS = [x[0] for x in Permission.PERMS]
1054 repo_read_perms = ['repository.read', 'repository.admin', 'repository.write']
1054 repo_read_perms = ['repository.read', 'repository.admin', 'repository.write']
1055 repo_group_read_perms = ['group.read', 'group.write', 'group.admin']
1055 repo_group_read_perms = ['group.read', 'group.write', 'group.admin']
1056 user_group_read_perms = ['usergroup.read', 'usergroup.write', 'usergroup.admin']
1056
1057
1057 def __init__(self, user_id=None, api_key=None, username=None, ip_addr=None):
1058 def __init__(self, user_id=None, api_key=None, username=None, ip_addr=None):
1058
1059
@@ -1292,7 +1293,7 b' class AuthUser(object):'
1292
1293
1293 def repo_acl_ids_from_stack(self, perms=None, prefix_filter=None, cache=False):
1294 def repo_acl_ids_from_stack(self, perms=None, prefix_filter=None, cache=False):
1294 if not perms:
1295 if not perms:
1295 perms = ['repository.read', 'repository.write', 'repository.admin']
1296 perms = AuthUser.repo_read_perms
1296 allowed_ids = []
1297 allowed_ids = []
1297 for k, stack_data in self.permissions['repositories'].perm_origin_stack.items():
1298 for k, stack_data in self.permissions['repositories'].perm_origin_stack.items():
1298 perm, origin, obj_id = stack_data[-1] # last item is the current permission
1299 perm, origin, obj_id = stack_data[-1] # last item is the current permission
@@ -1310,7 +1311,7 b' class AuthUser(object):'
1310 """
1311 """
1311 from rhodecode.model.scm import RepoList
1312 from rhodecode.model.scm import RepoList
1312 if not perms:
1313 if not perms:
1313 perms = ['repository.read', 'repository.write', 'repository.admin']
1314 perms = AuthUser.repo_read_perms
1314
1315
1315 def _cached_repo_acl(user_id, perm_def, _name_filter):
1316 def _cached_repo_acl(user_id, perm_def, _name_filter):
1316 qry = Repository.query()
1317 qry = Repository.query()
@@ -1326,7 +1327,7 b' class AuthUser(object):'
1326
1327
1327 def repo_group_acl_ids_from_stack(self, perms=None, prefix_filter=None, cache=False):
1328 def repo_group_acl_ids_from_stack(self, perms=None, prefix_filter=None, cache=False):
1328 if not perms:
1329 if not perms:
1329 perms = ['group.read', 'group.write', 'group.admin']
1330 perms = AuthUser.repo_group_read_perms
1330 allowed_ids = []
1331 allowed_ids = []
1331 for k, stack_data in self.permissions['repositories_groups'].perm_origin_stack.items():
1332 for k, stack_data in self.permissions['repositories_groups'].perm_origin_stack.items():
1332 perm, origin, obj_id = stack_data[-1] # last item is the current permission
1333 perm, origin, obj_id = stack_data[-1] # last item is the current permission
@@ -1344,7 +1345,7 b' class AuthUser(object):'
1344 """
1345 """
1345 from rhodecode.model.scm import RepoGroupList
1346 from rhodecode.model.scm import RepoGroupList
1346 if not perms:
1347 if not perms:
1347 perms = ['group.read', 'group.write', 'group.admin']
1348 perms = AuthUser.repo_group_read_perms
1348
1349
1349 def _cached_repo_group_acl(user_id, perm_def, _name_filter):
1350 def _cached_repo_group_acl(user_id, perm_def, _name_filter):
1350 qry = RepoGroup.query()
1351 qry = RepoGroup.query()
@@ -1360,7 +1361,7 b' class AuthUser(object):'
1360
1361
1361 def user_group_acl_ids_from_stack(self, perms=None, cache=False):
1362 def user_group_acl_ids_from_stack(self, perms=None, cache=False):
1362 if not perms:
1363 if not perms:
1363 perms = ['usergroup.read', 'usergroup.write', 'usergroup.admin']
1364 perms = AuthUser.user_group_read_perms
1364 allowed_ids = []
1365 allowed_ids = []
1365 for k, stack_data in self.permissions['user_groups'].perm_origin_stack.items():
1366 for k, stack_data in self.permissions['user_groups'].perm_origin_stack.items():
1366 perm, origin, obj_id = stack_data[-1] # last item is the current permission
1367 perm, origin, obj_id = stack_data[-1] # last item is the current permission
@@ -1376,7 +1377,7 b' class AuthUser(object):'
1376 """
1377 """
1377 from rhodecode.model.scm import UserGroupList
1378 from rhodecode.model.scm import UserGroupList
1378 if not perms:
1379 if not perms:
1379 perms = ['usergroup.read', 'usergroup.write', 'usergroup.admin']
1380 perms = AuthUser.user_group_read_perms
1380
1381
1381 def _cached_user_group_acl(user_id, perm_def, name_filter):
1382 def _cached_user_group_acl(user_id, perm_def, name_filter):
1382 qry = UserGroup.query()
1383 qry = UserGroup.query()
General Comments 0
You need to be logged in to leave comments. Login now