##// END OF EJS Templates
Add flag for permission check in _update_permissions function
marcink -
r3827:ff57547c beta
parent child Browse files
Show More
@@ -175,6 +175,7 b' class RepoModel(BaseModel):'
175 175 def get_repos_as_dict(self, repos_list=None, admin=False, perm_check=True,
176 176 super_user_actions=False):
177 177 _render = self._render_datatable
178 from pylons import tmpl_context as c
178 179
179 180 def quick_menu(repo_name):
180 181 return _render('quick_menu', repo_name)
@@ -198,7 +199,6 b' class RepoModel(BaseModel):'
198 199 cs_cache.get('message'))
199 200
200 201 def desc(desc):
201 from pylons import tmpl_context as c
202 202 if c.visual.stylify_metatags:
203 203 return h.urlify_text(h.desc_stylize(h.truncate(desc, 60)))
204 204 else:
@@ -460,8 +460,8 b' class RepoModel(BaseModel):'
460 460 enable_statistics, enable_locking, enable_downloads
461 461 )
462 462
463 def _update_permissions(self, repo, perms_new=None,
464 perms_updates=None):
463 def _update_permissions(self, repo, perms_new=None, perms_updates=None,
464 check_perms=True):
465 465 if not perms_new:
466 466 perms_new = []
467 467 if not perms_updates:
@@ -476,8 +476,8 b' class RepoModel(BaseModel):'
476 476 )
477 477 else:
478 478 #check if we have permissions to alter this usergroup
479 if HasUserGroupPermissionAny('usergroup.read', 'usergroup.write',
480 'usergroup.admin')(member):
479 req_perms = ('usergroup.read', 'usergroup.write', 'usergroup.admin')
480 if not check_perms or HasUserGroupPermissionAny(*req_perms)(member):
481 481 self.grant_users_group_permission(
482 482 repo=repo, group_name=member, perm=perm
483 483 )
@@ -489,8 +489,8 b' class RepoModel(BaseModel):'
489 489 )
490 490 else:
491 491 #check if we have permissions to alter this usergroup
492 if HasUserGroupPermissionAny('usergroup.read', 'usergroup.write',
493 'usergroup.admin')(member):
492 req_perms = ('usergroup.read', 'usergroup.write', 'usergroup.admin')
493 if not check_perms or HasUserGroupPermissionAny(*req_perms)(member):
494 494 self.grant_users_group_permission(
495 495 repo=repo, group_name=member, perm=perm
496 496 )
@@ -167,9 +167,11 b' class ReposGroupModel(BaseModel):'
167 167 raise
168 168
169 169 def _update_permissions(self, repos_group, perms_new=None,
170 perms_updates=None, recursive=False):
170 perms_updates=None, recursive=False,
171 check_perms=True):
171 172 from rhodecode.model.repo import RepoModel
172 173 from rhodecode.lib.auth import HasUserGroupPermissionAny
174
173 175 if not perms_new:
174 176 perms_new = []
175 177 if not perms_updates:
@@ -222,8 +224,8 b' class ReposGroupModel(BaseModel):'
222 224 ## set for user group
223 225 else:
224 226 #check if we have permissions to alter this usergroup
225 if HasUserGroupPermissionAny('usergroup.read', 'usergroup.write',
226 'usergroup.admin')(member):
227 req_perms = ('usergroup.read', 'usergroup.write', 'usergroup.admin')
228 if not check_perms or HasUserGroupPermissionAny(*req_perms)(member):
227 229 _set_perm_group(obj, users_group=member, perm=perm)
228 230 # set new permissions
229 231 for member, perm, member_type in perms_new:
@@ -231,8 +233,8 b' class ReposGroupModel(BaseModel):'
231 233 _set_perm_user(obj, user=member, perm=perm)
232 234 else:
233 235 #check if we have permissions to alter this usergroup
234 if HasUserGroupPermissionAny('usergroup.read', 'usergroup.write',
235 'usergroup.admin')(member):
236 req_perms = ('usergroup.read', 'usergroup.write', 'usergroup.admin')
237 if not check_perms or HasUserGroupPermissionAny(*req_perms)(member):
236 238 _set_perm_group(obj, users_group=member, perm=perm)
237 239 updates.append(obj)
238 240 #if it's not recursive call
General Comments 0
You need to be logged in to leave comments. Login now