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