Mercurial > kallithea
changeset 1735:344ddfeecce2 beta
small fixes for detection of groups that already exists
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 27 Nov 2011 01:03:12 +0200 |
parents | 48d4fcf04a29 |
children | e2d76554d2c6 |
files | rhodecode/model/forms.py |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/model/forms.py Sun Nov 27 00:50:19 2011 +0200 +++ b/rhodecode/model/forms.py Sun Nov 27 01:03:12 2011 +0200 @@ -120,15 +120,17 @@ class _ValidReposGroup(formencode.validators.FancyValidator): def validate_python(self, value, state): - #TODO WRITE VALIDATIONS + # TODO WRITE VALIDATIONS group_name = value.get('group_name') - group_parent_id = int(value.get('group_parent_id') or -1) + group_parent_id = value.get('group_parent_id') # slugify repo group just in case :) slug = repo_name_slug(group_name) # check for parent of self - if edit and old_data['group_id'] == group_parent_id: + parent_of_self = lambda:(old_data['group_id'] == int(group_parent_id) + if group_parent_id else False) + if edit and parent_of_self(): e_dict = {'group_parent_id':_('Cannot assign this group ' 'as parent')} raise formencode.Invalid('', value, state, @@ -136,10 +138,10 @@ old_gname = None if edit: - old_gname = RepoGroup.get( - old_data.get('group_id')).group_name + old_gname = RepoGroup.get(old_data.get('group_id')).group_name if old_gname != group_name or not edit: + # check filesystem gr = RepoGroup.query().filter(RepoGroup.group_name == slug)\ .filter(RepoGroup.group_parent_id == group_parent_id).scalar()