##// END OF EJS Templates
repo-groups: fixed a regression for updating nested repository groups
marcink -
r2241:74a4825b stable
parent child
Show More
@@ -169,7 +169,7 class RepoGroupSettingsView(RepoGroupApp
169
169
170 # use the new full name for redirect once we know we updated
170 # use the new full name for redirect once we know we updated
171 # the name on filesystem and in DB
171 # the name on filesystem and in DB
172 new_repo_group_name = schema_data['repo_group_name']
172 new_repo_group_name = schema_data['repo_group']['repo_group_name_with_group']
173
173
174 h.flash(_('Repository Group `{}` updated successfully').format(
174 h.flash(_('Repository Group `{}` updated successfully').format(
175 old_repo_group_name), category='success')
175 old_repo_group_name), category='success')
@@ -32,6 +32,11 def get_group_and_repo(repo_name):
32 repo_name, get_object=True)
32 repo_name, get_object=True)
33
33
34
34
35 def get_repo_group(repo_group_id):
36 from rhodecode.model.repo_group import RepoGroup
37 return RepoGroup.get(repo_group_id), RepoGroup.CHOICES_SEPARATOR
38
39
35 @colander.deferred
40 @colander.deferred
36 def deferred_can_write_to_group_validator(node, kw):
41 def deferred_can_write_to_group_validator(node, kw):
37 old_values = kw.get('old_values') or {}
42 old_values = kw.get('old_values') or {}
@@ -178,6 +183,7 class GroupType(colander.Mapping):
178 parent_group_name,
183 parent_group_name,
179 parent_group) = get_group_and_repo(validated_name)
184 parent_group) = get_group_and_repo(validated_name)
180
185
186 appstruct['repo_group_name_with_group'] = validated_name
181 appstruct['repo_group_name_without_group'] = repo_group_name_without_group
187 appstruct['repo_group_name_without_group'] = repo_group_name_without_group
182 appstruct['repo_group_name'] = parent_group_name or types.RootLocation
188 appstruct['repo_group_name'] = parent_group_name or types.RootLocation
183 if parent_group:
189 if parent_group:
@@ -271,6 +277,14 class RepoGroupSettingsSchema(RepoGroupS
271 appstruct = super(RepoGroupSchema, self).deserialize(cstruct)
277 appstruct = super(RepoGroupSchema, self).deserialize(cstruct)
272 validated_name = appstruct['repo_group_name']
278 validated_name = appstruct['repo_group_name']
273
279
280 # because of repoSchema adds repo-group as an ID, we inject it as
281 # full name here because validators require it, it's unwrapped later
282 # so it's safe to use and final name is going to be without group anyway
283
284 group, separator = get_repo_group(appstruct['repo_group'])
285 if group:
286 validated_name = separator.join([group.group_name, validated_name])
287
274 # second pass to validate permissions to repo_group
288 # second pass to validate permissions to repo_group
275 second = RepoGroupAccessSchema().bind(**self.bindings)
289 second = RepoGroupAccessSchema().bind(**self.bindings)
276 appstruct_second = second.deserialize({'repo_group': validated_name})
290 appstruct_second = second.deserialize({'repo_group': validated_name})
@@ -60,6 +60,7 class TestRepoGroupSchema(object):
60 assert schema_data['repo_group'] == {
60 assert schema_data['repo_group'] == {
61 'repo_group_id': None,
61 'repo_group_id': None,
62 'repo_group_name': types.RootLocation,
62 'repo_group_name': types.RootLocation,
63 'repo_group_name_with_group': u'my_schema_group',
63 'repo_group_name_without_group': u'my_schema_group'}
64 'repo_group_name_without_group': u'my_schema_group'}
64
65
65 @pytest.mark.parametrize('given, err_key, expected_exc', [
66 @pytest.mark.parametrize('given, err_key, expected_exc', [
@@ -96,6 +97,7 class TestRepoGroupSchema(object):
96 assert schema_data['repo_group'] == {
97 assert schema_data['repo_group'] == {
97 'repo_group_id': test_repo_group.group_id,
98 'repo_group_id': test_repo_group.group_id,
98 'repo_group_name': test_repo_group.group_name,
99 'repo_group_name': test_repo_group.group_name,
100 'repo_group_name_with_group': full_name,
99 'repo_group_name_without_group': u'my_schema_group'}
101 'repo_group_name_without_group': u'my_schema_group'}
100
102
101 def test_deserialize_with_group_name_regular_user_no_perms(
103 def test_deserialize_with_group_name_regular_user_no_perms(
General Comments 0
You need to be logged in to leave comments. Login now