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