##// END OF EJS Templates
permissions: use constant for fork enable/disable
milka -
r4663:b7737b7b default
parent child Browse files
Show More
@@ -1212,7 +1212,7 b' def fork_repo(request, apiuser, repoid, '
1212 1212 validate_repo_permissions(apiuser, repoid, repo, _perms)
1213 1213
1214 1214 # check if the regular user has at least fork permissions as well
1215 if not HasPermissionAnyApi('hg.fork.repository')(user=apiuser):
1215 if not HasPermissionAnyApi(PermissionModel.FORKING_ENABLED)(user=apiuser):
1216 1216 raise JSONRPCForbidden()
1217 1217
1218 1218 # check if user can set owner parameter
@@ -165,7 +165,7 b' class RepoForksView(RepoAppView, DataGri'
165 165
166 166 @LoginRequired()
167 167 @NotAnonymous()
168 @HasPermissionAnyDecorator('hg.admin', 'hg.fork.repository')
168 @HasPermissionAnyDecorator('hg.admin', PermissionModel.FORKING_ENABLED)
169 169 @HasRepoPermissionAnyDecorator(
170 170 'repository.read', 'repository.write', 'repository.admin')
171 171 def repo_fork_new(self):
@@ -191,7 +191,7 b' class RepoForksView(RepoAppView, DataGri'
191 191
192 192 @LoginRequired()
193 193 @NotAnonymous()
194 @HasPermissionAnyDecorator('hg.admin', 'hg.fork.repository')
194 @HasPermissionAnyDecorator('hg.admin', PermissionModel.FORKING_ENABLED)
195 195 @HasRepoPermissionAnyDecorator(
196 196 'repository.read', 'repository.write', 'repository.admin')
197 197 @CSRFRequired()
@@ -524,8 +524,10 b' class PermissionCalculator(object):'
524 524
525 525 # In case we want to extend this list we should make sure
526 526 # this is in sync with User.DEFAULT_USER_PERMISSIONS definitions
527 from rhodecode.model.permission import PermissionModel
528
527 529 _configurable = frozenset([
528 'hg.fork.none', 'hg.fork.repository',
530 PermissionModel.FORKING_DISABLED, PermissionModel.FORKING_ENABLED,
529 531 'hg.create.none', 'hg.create.repository',
530 532 'hg.usergroup.create.false', 'hg.usergroup.create.true',
531 533 'hg.repogroup.create.false', 'hg.repogroup.create.true',
@@ -41,6 +41,8 b' class PermissionModel(BaseModel):'
41 41 """
42 42 Permissions model for RhodeCode
43 43 """
44 FORKING_DISABLED = 'hg.fork.none'
45 FORKING_ENABLED = 'hg.fork.repository'
44 46
45 47 cls = Permission
46 48 global_perms = {
@@ -122,8 +124,8 b' class PermissionModel(BaseModel):'
122 124 ('hg.repogroup.create.true', _('Enabled'))]
123 125
124 126 c_obj.fork_choices = [
125 ('hg.fork.none', _('Disabled')),
126 ('hg.fork.repository', _('Enabled'))]
127 (self.FORKING_DISABLED, _('Disabled')),
128 (self.FORKING_ENABLED, _('Enabled'))]
127 129
128 130 c_obj.inherit_default_permission_choices = [
129 131 ('hg.inherit_default_perms.false', _('Disabled')),
General Comments 0
You need to be logged in to leave comments. Login now