##// END OF EJS Templates
repositories: allow updating repository settings for users without store-in-root permissions...
marcink -
r4415:fc1f6c1b default
parent child Browse files
Show More
@@ -141,17 +141,23 b' def deferred_can_write_to_group_validato'
141 141
142 142 is_root_location = value is types.RootLocation
143 143 # NOT initialized validators, we must call them
144 can_create_repos_at_root = HasPermissionAny(
145 'hg.admin', 'hg.create.repository')
144 can_create_repos_at_root = HasPermissionAny('hg.admin', 'hg.create.repository')
146 145
147 146 # if values is root location, we simply need to check if we can write
148 147 # to root location !
149 148 if is_root_location:
149
150 150 if can_create_repos_at_root(user=request_user):
151 151 # we can create repo group inside tool-level. No more checks
152 152 # are required
153 153 return
154 154 else:
155 old_name = old_values.get('repo_name')
156 if old_name and old_name == old_values.get('submitted_repo_name'):
157 # since we didn't change the name, we can skip validation and
158 # allow current users without store-in-root permissions to update
159 return
160
155 161 # "fake" node name as repo_name, otherwise we oddly report
156 162 # the error as if it was coming form repo_group
157 163 # however repo_group is empty when using root location.
@@ -372,6 +378,9 b' class RepoSchema(colander.MappingSchema)'
372 378 validated_name = appstruct['repo_name']
373 379
374 380 # second pass to validate permissions to repo_group
381 if 'old_values' in self.bindings:
382 # save current repo name for name change checks
383 self.bindings['old_values']['submitted_repo_name'] = validated_name
375 384 second = RepoGroupAccessSchema().bind(**self.bindings)
376 385 appstruct_second = second.deserialize({'repo_group': validated_name})
377 386 # save result
@@ -429,6 +438,9 b' class RepoSettingsSchema(RepoSchema):'
429 438 validated_name = separator.join([group.group_name, validated_name])
430 439
431 440 # second pass to validate permissions to repo_group
441 if 'old_values' in self.bindings:
442 # save current repo name for name change checks
443 self.bindings['old_values']['submitted_repo_name'] = validated_name
432 444 second = RepoGroupAccessSchema().bind(**self.bindings)
433 445 appstruct_second = second.deserialize({'repo_group': validated_name})
434 446 # save result
General Comments 0
You need to be logged in to leave comments. Login now