Mercurial > kallithea
diff rhodecode/model/forms.py @ 1347:43b8e161be3f beta
#47 implemented basic edition of groups
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 25 May 2011 10:27:29 +0200 |
parents | cf78d302d441 |
children | 526120c77a38 |
line wrap: on
line diff
--- a/rhodecode/model/forms.py Mon May 23 02:46:43 2011 +0200 +++ b/rhodecode/model/forms.py Wed May 25 10:27:29 2011 +0200 @@ -117,25 +117,31 @@ def ValidReposGroup(edit, old_data): - class _ValidReposGroup(formencode.validators.FancyValidator): def validate_python(self, value, state): #TODO WRITE VALIDATIONS - group_name = value.get('repos_group_name') - parent_id = value.get('repos_group_parent') + group_name = value.get('group_name') + group_parent_id = value.get('group_parent_id') # slugify repo group just in case :) slug = repo_name_slug(group_name) - # check filesystem - gr = Group.query().filter(Group.group_name == slug)\ - .filter(Group.group_parent_id == parent_id).scalar() + old_gname = None + if edit: + old_gname = Group.get( + old_data.get('group_id')).group_name - if gr: - e_dict = {'repos_group_name':_('This group already exists')} - raise formencode.Invalid('', value, state, - error_dict=e_dict) + if old_gname != group_name or not edit: + # check filesystem + gr = Group.query().filter(Group.group_name == slug)\ + .filter(Group.group_parent_id == group_parent_id).scalar() + + if gr: + e_dict = {'group_name':_('This group already exists')} + raise formencode.Invalid('', value, state, + error_dict=e_dict) + return _ValidReposGroup class ValidPassword(formencode.validators.FancyValidator): @@ -502,11 +508,11 @@ allow_extra_fields = True filter_extra_fields = True - repos_group_name = All(UnicodeString(strip=True, min=1, not_empty=True), + group_name = All(UnicodeString(strip=True, min=1, not_empty=True), SlugifyName()) - repos_group_description = UnicodeString(strip=True, min=1, + group_description = UnicodeString(strip=True, min=1, not_empty=True) - repos_group_parent = OneOf(available_groups, hideList=False, + group_parent_id = OneOf(available_groups, hideList=False, testValueList=True, if_missing=None, not_empty=False)