diff options
author | Marcin Kuzminski <marcin@python-works.com> | 2011-04-19 17:28:42 +0200 |
---|---|---|
committer | Marcin Kuzminski <marcin@python-works.com> | 2011-04-19 17:28:42 +0200 |
commit | 2b543f4a3343253b34e0166532e25381076c4455 (patch) | |
tree | 1206f6062c5aa844f2c1e7fbc39df3a1c6298a7b /rhodecode/model/forms.py | |
parent | 43e8612d92e85c61d47c933d8414f25c309d8b1e (diff) |
Fixed permissions for users groups, group can have create repo permission now.
Some code refactor + pep8ify
--HG--
branch : beta
Diffstat (limited to 'rhodecode/model/forms.py')
-rw-r--r-- | rhodecode/model/forms.py | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py index 47847305..986f505f 100644 --- a/rhodecode/model/forms.py +++ b/rhodecode/model/forms.py @@ -37,7 +37,6 @@ from rhodecode.lib.exceptions import LdapImportError from rhodecode.model import meta from rhodecode.model.user import UserModel from rhodecode.model.repo import RepoModel -from rhodecode.model.users_group import UsersGroupModel from rhodecode.model.db import User, UsersGroup from rhodecode import BACKENDS @@ -47,9 +46,9 @@ log = logging.getLogger(__name__) class State_obj(object): _ = staticmethod(_) -#=============================================================================== +#============================================================================== # VALIDATORS -#=============================================================================== +#============================================================================== class ValidAuthToken(formencode.validators.FancyValidator): messages = {'invalid_token':_('Token mismatch')} @@ -73,23 +72,19 @@ def ValidUsername(edit, old_data): if old_un != value or not edit: if UserModel().get_by_username(value, cache=False, case_insensitive=True): - raise formencode.Invalid(_('This username already exists') , - value, state) - + raise formencode.Invalid(_('This username already ' + 'exists') , value, state) if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None: raise formencode.Invalid(_('Username may only contain ' - 'alphanumeric characters underscores, ' - 'periods or dashes and must begin with ' - 'alphanumeric character'), - value, state) - - + 'alphanumeric characters ' + 'underscores, periods or dashes ' + 'and must begin with alphanumeric ' + 'character'), value, state) return _ValidUsername - def ValidUsersGroup(edit, old_data): class _ValidUsersGroup(formencode.validators.FancyValidator): @@ -100,22 +95,23 @@ def ValidUsersGroup(edit, old_data): #check if group is unique old_ugname = None if edit: - old_ugname = UsersGroupModel()\ - .get(old_data.get('users_group_id')).users_group_name + old_ugname = UsersGroup.get( + old_data.get('users_group_id')).users_group_name if old_ugname != value or not edit: - if UsersGroupModel().get_by_groupname(value, cache=False, + if UsersGroup.get_by_group_name(value, cache=False, case_insensitive=True): - raise formencode.Invalid(_('This users group already exists') , - value, state) + raise formencode.Invalid(_('This users group ' + 'already exists') , value, + state) if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None: raise formencode.Invalid(_('Group name may only contain ' - 'alphanumeric characters underscores, ' - 'periods or dashes and must begin with ' - 'alphanumeric character'), - value, state) + 'alphanumeric characters ' + 'underscores, periods or dashes ' + 'and must begin with alphanumeric ' + 'character'), value, state) return _ValidUsersGroup |