Show More
@@ -239,8 +239,10 b' class ReposController(BaseRepoController' | |||||
239 | #override the choices with extracted revisions ! |
|
239 | #override the choices with extracted revisions ! | |
240 | choices, c.landing_revs = ScmModel().get_repo_landing_revs(repo_name) |
|
240 | choices, c.landing_revs = ScmModel().get_repo_landing_revs(repo_name) | |
241 | c.landing_revs_choices = choices |
|
241 | c.landing_revs_choices = choices | |
242 |
|
242 | repo = Repository.get_by_repo_name(repo_name) | ||
243 |
_form = RepoForm(edit=True, old_data={'repo_name': repo_name |
|
243 | _form = RepoForm(edit=True, old_data={'repo_name': repo_name, | |
|
244 | 'repo_group': repo.group.get_dict() \ | |||
|
245 | if repo.group else {}}, | |||
244 | repo_groups=c.repo_groups_choices, |
|
246 | repo_groups=c.repo_groups_choices, | |
245 | landing_revs=c.landing_revs_choices)() |
|
247 | landing_revs=c.landing_revs_choices)() | |
246 | try: |
|
248 | try: |
@@ -109,9 +109,11 b' class SettingsController(BaseRepoControl' | |||||
109 | #override the choices with extracted revisions ! |
|
109 | #override the choices with extracted revisions ! | |
110 | choices, c.landing_revs = ScmModel().get_repo_landing_revs(repo_name) |
|
110 | choices, c.landing_revs = ScmModel().get_repo_landing_revs(repo_name) | |
111 | c.landing_revs_choices = choices |
|
111 | c.landing_revs_choices = choices | |
112 |
|
112 | repo = Repository.get_by_repo_name(repo_name) | ||
113 | _form = RepoSettingsForm(edit=True, |
|
113 | _form = RepoSettingsForm(edit=True, | |
114 |
|
|
114 | old_data={'repo_name': repo_name, | |
|
115 | 'repo_group': repo.group.get_dict() \ | |||
|
116 | if repo.group else {}}, | |||
115 | repo_groups=c.repo_groups_choices, |
|
117 | repo_groups=c.repo_groups_choices, | |
116 | landing_revs=c.landing_revs_choices)() |
|
118 | landing_revs=c.landing_revs_choices)() | |
117 | try: |
|
119 | try: |
@@ -182,7 +182,7 b' def RepoForm(edit=False, old_data={}, su' | |||||
182 | filter_extra_fields = False |
|
182 | filter_extra_fields = False | |
183 | repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True), |
|
183 | repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True), | |
184 | v.SlugifyName()) |
|
184 | v.SlugifyName()) | |
185 | repo_group = All(v.CanWriteGroup(), |
|
185 | repo_group = All(v.CanWriteGroup(old_data), | |
186 | v.OneOf(repo_groups, hideList=True)) |
|
186 | v.OneOf(repo_groups, hideList=True)) | |
187 | repo_type = v.OneOf(supported_backends) |
|
187 | repo_type = v.OneOf(supported_backends) | |
188 | repo_description = v.UnicodeString(strip=True, min=1, not_empty=False) |
|
188 | repo_description = v.UnicodeString(strip=True, min=1, not_empty=False) | |
@@ -227,7 +227,7 b' def RepoSettingsForm(edit=False, old_dat' | |||||
227 | filter_extra_fields = False |
|
227 | filter_extra_fields = False | |
228 | repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True), |
|
228 | repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True), | |
229 | v.SlugifyName()) |
|
229 | v.SlugifyName()) | |
230 | repo_group = All(v.CanWriteGroup(), |
|
230 | repo_group = All(v.CanWriteGroup(old_data), | |
231 | v.OneOf(repo_groups, hideList=True)) |
|
231 | v.OneOf(repo_groups, hideList=True)) | |
232 | repo_description = v.UnicodeString(strip=True, min=1, not_empty=False) |
|
232 | repo_description = v.UnicodeString(strip=True, min=1, not_empty=False) | |
233 | repo_private = v.StringBoolean(if_missing=False) |
|
233 | repo_private = v.StringBoolean(if_missing=False) |
@@ -16,6 +16,7 b' from formencode.validators import (' | |||||
16 | from rhodecode.lib.compat import OrderedSet |
|
16 | from rhodecode.lib.compat import OrderedSet | |
17 | from rhodecode.lib import ipaddr |
|
17 | from rhodecode.lib import ipaddr | |
18 | from rhodecode.lib.utils import repo_name_slug |
|
18 | from rhodecode.lib.utils import repo_name_slug | |
|
19 | from rhodecode.lib.utils2 import safe_int | |||
19 | from rhodecode.model.db import RepoGroup, Repository, UserGroup, User,\ |
|
20 | from rhodecode.model.db import RepoGroup, Repository, UserGroup, User,\ | |
20 | ChangesetStatus |
|
21 | ChangesetStatus | |
21 | from rhodecode.lib.exceptions import LdapImportError |
|
22 | from rhodecode.lib.exceptions import LdapImportError | |
@@ -472,7 +473,7 b' def ValidForkType(old_data={}):' | |||||
472 | return _validator |
|
473 | return _validator | |
473 |
|
474 | |||
474 |
|
475 | |||
475 | def CanWriteGroup(): |
|
476 | def CanWriteGroup(old_data=None): | |
476 | class _validator(formencode.validators.FancyValidator): |
|
477 | class _validator(formencode.validators.FancyValidator): | |
477 | messages = { |
|
478 | messages = { | |
478 | 'permission_denied': _(u"You don't have permissions " |
|
479 | 'permission_denied': _(u"You don't have permissions " | |
@@ -493,18 +494,20 b' def CanWriteGroup():' | |||||
493 | val = HasReposGroupPermissionAny('group.write', 'group.admin') |
|
494 | val = HasReposGroupPermissionAny('group.write', 'group.admin') | |
494 | can_create_repos = HasPermissionAny('hg.admin', 'hg.create.repository') |
|
495 | can_create_repos = HasPermissionAny('hg.admin', 'hg.create.repository') | |
495 | forbidden = not val(gr_name, 'can write into group validator') |
|
496 | forbidden = not val(gr_name, 'can write into group validator') | |
496 | #parent group need to be existing |
|
497 | value_changed = True # old_data['repo_group'].get('group_id') != safe_int(value) | |
497 | if gr and forbidden: |
|
498 | if value_changed: # do check if we changed the value | |
498 | msg = M(self, 'permission_denied', state) |
|
499 | #parent group need to be existing | |
499 | raise formencode.Invalid(msg, value, state, |
|
500 | if gr and forbidden: | |
500 | error_dict=dict(repo_type=msg) |
|
501 | msg = M(self, 'permission_denied', state) | |
501 | ) |
|
502 | raise formencode.Invalid(msg, value, state, | |
502 | ## check if we can write to root location ! |
|
503 | error_dict=dict(repo_type=msg) | |
503 | elif gr is None and can_create_repos() is False: |
|
504 | ) | |
504 | msg = M(self, 'permission_denied_root', state) |
|
505 | ## check if we can write to root location ! | |
505 | raise formencode.Invalid(msg, value, state, |
|
506 | elif gr is None and can_create_repos() is False: | |
506 | error_dict=dict(repo_type=msg) |
|
507 | msg = M(self, 'permission_denied_root', state) | |
507 | ) |
|
508 | raise formencode.Invalid(msg, value, state, | |
|
509 | error_dict=dict(repo_type=msg) | |||
|
510 | ) | |||
508 |
|
511 | |||
509 | return _validator |
|
512 | return _validator | |
510 |
|
513 |
General Comments 0
You need to be logged in to leave comments.
Login now