##// END OF EJS Templates
utils/conf...
utils/conf - created temporary utils2 - made config.conf for storing some configurations - fixed some dependency import problems - code cleanup - rc-extensions now properly work for celery

File last commit:

r2074:6c6718c0 merge default
r2109:8ecfed1d beta
Show More
forms.py
773 lines | 28.9 KiB | text/x-python | PythonLexer
renamed project to rhodecode
r547 """ this is forms validation classes
http://formencode.org/module-formencode.validators.html
for list off all availible validators
we can create our own validators
The table below outlines the options which can be used in a schema in addition to the validators themselves
pre_validators [] These validators will be applied before the schema
chained_validators [] These validators will be applied after the schema
allow_extra_fields False If True, then it is not an error when keys that aren't associated with a validator are present
filter_extra_fields False If True, then keys that aren't associated with a validator are removed
if_key_missing NoDefault If this is given, then any keys that aren't available but are expected will be replaced with this value (and then validated). This does not override a present .if_missing attribute on validators. NoDefault is a special FormEncode class to mean that no default values has been specified and therefore missing keys shouldn't take a default value.
source code cleanup: remove trailing white space, normalize file endings
r1203 ignore_key_missing False If True, then missing keys will be missing in the result, if the validator doesn't have .if_missing on it already
renamed project to rhodecode
r547 <name> = formencode.validators.<name of validator>
<name> must equal form name
list=[1,2,3,4,5]
for SELECT use formencode.All(OneOf(list), Int())
source code cleanup: remove trailing white space, normalize file endings
r1203
renamed project to rhodecode
r547 """
ldap auth rewrite, moved split authfunc into two functions,...
r761 import os
import re
import logging
fixed http/s validation for clone_uri, and missing return value.
r1298 import traceback
ldap auth rewrite, moved split authfunc into two functions,...
r761
import formencode
renamed project to rhodecode
r547 from formencode import All
from formencode.validators import UnicodeString, OneOf, Int, Number, Regex, \
#56 implemented users groups editing,...
r972 Email, Bool, StringBoolean, Set
ldap auth rewrite, moved split authfunc into two functions,...
r761
renamed project to rhodecode
r547 from pylons.i18n.translation import _
Code refactor number 2
r1022 from webhelpers.pylonslib.secure_form import authentication_token
ldap auth rewrite, moved split authfunc into two functions,...
r761
fixed hardcoded admin prefix check in forms
r1533 from rhodecode.config.routing import ADMIN_PREFIX
Code refactor number 2
r1022 from rhodecode.lib.utils import repo_name_slug
ldap auth rewrite, moved split authfunc into two functions,...
r761 from rhodecode.lib.auth import authenticate, get_crypt_password
implements #60, ldap configuration and authentication....
r705 from rhodecode.lib.exceptions import LdapImportError
commit less models...
r1749 from rhodecode.model.db import User, UsersGroup, RepoGroup, Repository
ldap auth rewrite, moved split authfunc into two functions,...
r761 from rhodecode import BACKENDS
renamed project to rhodecode
r547 log = logging.getLogger(__name__)
added validation to repo groups to check for conflicting repository name fixes #337
r1898
renamed project to rhodecode
r547 #this is needed to translate the messages using _() in validators
class State_obj(object):
_ = staticmethod(_)
Code refactoring,models renames...
r629
added validation to repo groups to check for conflicting repository name fixes #337
r1898
Fixed permissions for users groups, group can have create repo permission now....
r1271 #==============================================================================
renamed project to rhodecode
r547 # VALIDATORS
Fixed permissions for users groups, group can have create repo permission now....
r1271 #==============================================================================
renamed project to rhodecode
r547 class ValidAuthToken(formencode.validators.FancyValidator):
#344 optional firstname lastname on user creation...
r1950 messages = {'invalid_token': _('Token mismatch')}
renamed project to rhodecode
r547
def validate_python(self, value, state):
if value != authentication_token():
#344 optional firstname lastname on user creation...
r1950 raise formencode.Invalid(
self.message('invalid_token',
state, search_number=value),
value,
state
)
Code refactoring,models renames...
r629
added validation to repo groups to check for conflicting repository name fixes #337
r1898
Code refactoring,models renames...
r629 def ValidUsername(edit, old_data):
renamed project to rhodecode
r547 class _ValidUsername(formencode.validators.FancyValidator):
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 def validate_python(self, value, state):
if value in ['default', 'new_user']:
raise formencode.Invalid(_('Invalid username'), value, state)
Code refactoring,models renames...
r629 #check if user is unique
renamed project to rhodecode
r547 old_un = None
if edit:
commit less models...
r1749 old_un = User.get(old_data.get('user_id')).username
Code refactoring,models renames...
r629
if old_un != value or not edit:
Refactoring of model get functions
r1530 if User.get_by_username(value, case_insensitive=True):
Fixed permissions for users groups, group can have create repo permission now....
r1271 raise formencode.Invalid(_('This username already '
'exists') , value, state)
added test for username and email case senstitive validators,...
r745
fixed #102 allowed '.' character in username
r960 if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None:
#344 optional firstname lastname on user creation...
r1950 raise formencode.Invalid(
_('Username may only contain alphanumeric characters '
'underscores, periods or dashes and must begin with '
white space cleanup
r1963 'alphanumeric character'),
value,
#344 optional firstname lastname on user creation...
r1950 state
)
added test for username and email case senstitive validators,...
r745
Code refactoring,models renames...
r629 return _ValidUsername
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959
def ValidUsersGroup(edit, old_data):
class _ValidUsersGroup(formencode.validators.FancyValidator):
def validate_python(self, value, state):
if value in ['default']:
raise formencode.Invalid(_('Invalid group name'), value, state)
#check if group is unique
#56 implemented users groups editing,...
r972 old_ugname = None
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959 if edit:
Fixed permissions for users groups, group can have create repo permission now....
r1271 old_ugname = UsersGroup.get(
old_data.get('users_group_id')).users_group_name
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959
#56 implemented users groups editing,...
r972 if old_ugname != value or not edit:
Fixed permissions for users groups, group can have create repo permission now....
r1271 if UsersGroup.get_by_group_name(value, cache=False,
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959 case_insensitive=True):
Fixed permissions for users groups, group can have create repo permission now....
r1271 raise formencode.Invalid(_('This users group '
#344 optional firstname lastname on user creation...
r1950 'already exists'), value,
Fixed permissions for users groups, group can have create repo permission now....
r1271 state)
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959
if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None:
#344 optional firstname lastname on user creation...
r1950 raise formencode.Invalid(
_('RepoGroup name may only contain alphanumeric characters '
'underscores, periods or dashes and must begin with '
white space cleanup
r1963 'alphanumeric character'),
value,
#344 optional firstname lastname on user creation...
r1950 state
)
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959
return _ValidUsersGroup
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 def ValidReposGroup(edit, old_data):
class _ValidReposGroup(formencode.validators.FancyValidator):
def validate_python(self, value, state):
small fixes for detection of groups that already exists
r1735 # TODO WRITE VALIDATIONS
#47 implemented basic edition of groups
r1347 group_name = value.get('group_name')
small fixes for detection of groups that already exists
r1735 group_parent_id = value.get('group_parent_id')
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345
# slugify repo group just in case :)
slug = repo_name_slug(group_name)
#47 added editing of groups, and moving them between. Added check constraint for groups...
r1349 # check for parent of self
added validation to repo groups to check for conflicting repository name fixes #337
r1898 parent_of_self = lambda: (
old_data['group_id'] == int(group_parent_id)
if group_parent_id else False
)
small fixes for detection of groups that already exists
r1735 if edit and parent_of_self():
added validation to repo groups to check for conflicting repository name fixes #337
r1898 e_dict = {
'group_parent_id': _('Cannot assign this group as parent')
}
#47 added editing of groups, and moving them between. Added check constraint for groups...
r1349 raise formencode.Invalid('', value, state,
error_dict=e_dict)
#47 implemented basic edition of groups
r1347 old_gname = None
if edit:
small fixes for detection of groups that already exists
r1735 old_gname = RepoGroup.get(old_data.get('group_id')).group_name
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345
#47 implemented basic edition of groups
r1347 if old_gname != group_name or not edit:
small fixes for detection of groups that already exists
r1735
added validation to repo groups to check for conflicting repository name fixes #337
r1898 # check group
gr = RepoGroup.query()\
.filter(RepoGroup.group_name == slug)\
.filter(RepoGroup.group_parent_id == group_parent_id)\
.scalar()
#47 implemented basic edition of groups
r1347
if gr:
added validation to repo groups to check for conflicting repository name fixes #337
r1898 e_dict = {
'group_name': _('This group already exists')
}
raise formencode.Invalid('', value, state,
error_dict=e_dict)
# check for same repo
repo = Repository.query()\
.filter(Repository.repo_name == slug)\
.scalar()
if repo:
e_dict = {
'group_name': _('Repository with this name already exists')
}
#47 implemented basic edition of groups
r1347 raise formencode.Invalid('', value, state,
error_dict=e_dict)
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 return _ValidReposGroup
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959
added validation to repo groups to check for conflicting repository name fixes #337
r1898
renamed project to rhodecode
r547 class ValidPassword(formencode.validators.FancyValidator):
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 def to_python(self, value, state):
fixes #69 password confirmation for register dialog....
r722
#344 optional firstname lastname on user creation...
r1950 if not value:
return
fixes #69 password confirmation for register dialog....
r722
#344 optional firstname lastname on user creation...
r1950 if value.get('password'):
try:
value['password'] = get_crypt_password(value['password'])
except UnicodeEncodeError:
e_dict = {'password': _('Invalid characters in password')}
raise formencode.Invalid('', value, state, error_dict=e_dict)
fixes #69 password confirmation for register dialog....
r722
#344 optional firstname lastname on user creation...
r1950 if value.get('password_confirmation'):
try:
value['password_confirmation'] = \
get_crypt_password(value['password_confirmation'])
except UnicodeEncodeError:
e_dict = {
'password_confirmation': _('Invalid characters in password')
}
raise formencode.Invalid('', value, state, error_dict=e_dict)
fixes #69 password confirmation for register dialog....
r722
#344 optional firstname lastname on user creation...
r1950 if value.get('new_password'):
try:
value['new_password'] = \
get_crypt_password(value['new_password'])
except UnicodeEncodeError:
e_dict = {'new_password': _('Invalid characters in password')}
raise formencode.Invalid('', value, state, error_dict=e_dict)
fixed bug in forms found due to testing,...
r728
#344 optional firstname lastname on user creation...
r1950 return value
fixes #69 password confirmation for register dialog....
r722
added validation to repo groups to check for conflicting repository name fixes #337
r1898
fixes #69 password confirmation for register dialog....
r722 class ValidPasswordsMatch(formencode.validators.FancyValidator):
def validate_python(self, value, state):
#235 forking page repo group selection...
r1722
implements #237 added password confirmation for my account and admin edit user.
r1597 pass_val = value.get('password') or value.get('new_password')
if pass_val != value['password_confirmation']:
fixes #69 password confirmation for register dialog....
r722 e_dict = {'password_confirmation':
Augusto Herrmann
Added pt_BR localization, added i18n wrappers on some places missing, fixed css in settings screen for longer labels.
r1472 _('Passwords do not match')}
fixes #69 password confirmation for register dialog....
r722 raise formencode.Invalid('', value, state, error_dict=e_dict)
Code refactoring,models renames...
r629
added validation to repo groups to check for conflicting repository name fixes #337
r1898
renamed project to rhodecode
r547 class ValidAuth(formencode.validators.FancyValidator):
messages = {
fixes #288...
r1594 'invalid_password':_('invalid password'),
'invalid_login':_('invalid user name'),
'disabled_account':_('Your account is disabled')
}
#235 forking page repo group selection...
r1722
fixes #288...
r1594 # error mapping
#344 optional firstname lastname on user creation...
r1950 e_dict = {'username': messages['invalid_login'],
'password': messages['invalid_password']}
e_dict_disable = {'username': messages['disabled_account']}
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 def validate_python(self, value, state):
password = value['password']
username = value['username']
Refactoring of model get functions
r1530 user = User.get_by_username(username)
#235 forking page repo group selection...
r1722
ldap auth rewrite, moved split authfunc into two functions,...
r761 if authenticate(username, password):
Code refactor for auth func, preparing for ldap support...
r699 return value
else:
if user and user.active is False:
garden...
r1976 log.warning('user %s is disabled' % username)
#344 optional firstname lastname on user creation...
r1950 raise formencode.Invalid(
self.message('disabled_account',
state=State_obj),
value, state,
error_dict=self.e_dict_disable
)
Code refactor for auth func, preparing for ldap support...
r699 else:
more work on improving info logging
r2025 log.warning('user %s failed to authenticate' % username)
#344 optional firstname lastname on user creation...
r1950 raise formencode.Invalid(
self.message('invalid_password',
state=State_obj), value, state,
error_dict=self.e_dict
)
Code refactoring,models renames...
r629
added validation to repo groups to check for conflicting repository name fixes #337
r1898
renamed project to rhodecode
r547 class ValidRepoUser(formencode.validators.FancyValidator):
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 def to_python(self, value, state):
try:
fixed #47 adding a new repo that have a group chosen had wrong paths.
r1361 User.query().filter(User.active == True)\
renamed project to rhodecode
r547 .filter(User.username == value).one()
except Exception:
raise formencode.Invalid(_('This username is not valid'),
value, state)
fixed saving settings on repositories inside groups, also fixes #187...
r1323 return value
renamed project to rhodecode
r547
added validation to repo groups to check for conflicting repository name fixes #337
r1898
Code refactoring,models renames...
r629 def ValidRepoName(edit, old_data):
renamed project to rhodecode
r547 class _ValidRepoName(formencode.validators.FancyValidator):
fixed saving settings on repositories inside groups, also fixes #187...
r1323 def to_python(self, value, state):
Code refactoring,models renames...
r629
fixed saving settings on repositories inside groups, also fixes #187...
r1323 repo_name = value.get('repo_name')
slug = repo_name_slug(repo_name)
fixed hardcoded admin prefix check in forms
r1533 if slug in [ADMIN_PREFIX, '']:
fixed saving settings on repositories inside groups, also fixes #187...
r1323 e_dict = {'repo_name': _('This repository name is disallowed')}
raise formencode.Invalid('', value, state, error_dict=e_dict)
fixed regresion made in previos commit, that introduced bug in handling regular repositories
r1324 if value.get('repo_group'):
refactoring of models names for repoGroup permissions
r1633 gr = RepoGroup.get(value.get('repo_group'))
fixed regresion made in previos commit, that introduced bug in handling regular repositories
r1324 group_path = gr.full_path
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
r1346 # value needs to be aware of group name in order to check
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
r1550 # db key This is an actual just the name to store in the
fixed #47 adding a new repo that have a group chosen had wrong paths.
r1361 # database
refactoring of models names for repoGroup permissions
r1633 repo_name_full = group_path + RepoGroup.url_sep() + repo_name
#235 forking page repo group selection...
r1722
fixed regresion made in previos commit, that introduced bug in handling regular repositories
r1324 else:
group_path = ''
repo_name_full = repo_name
fixed saving settings on repositories inside groups, also fixes #187...
r1323 value['repo_name_full'] = repo_name_full
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
r1550 rename = old_data.get('repo_name') != repo_name_full
create = not edit
if rename or create:
fixed saving settings on repositories inside groups, also fixes #187...
r1323
fixed regresion made in previos commit, that introduced bug in handling regular repositories
r1324 if group_path != '':
commit less models...
r1749 if Repository.get_by_repo_name(repo_name_full):
#344 optional firstname lastname on user creation...
r1950 e_dict = {
'repo_name': _('This repository already exists in '
'a group "%s"') % gr.group_name
}
fixed saving settings on repositories inside groups, also fixes #187...
r1323 raise formencode.Invalid('', value, state,
error_dict=e_dict)
refactoring of models names for repoGroup permissions
r1633 elif RepoGroup.get_by_group_name(repo_name_full):
#344 optional firstname lastname on user creation...
r1950 e_dict = {
'repo_name': _('There is a group with this name '
'already "%s"') % repo_name_full
}
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
r1550 raise formencode.Invalid('', value, state,
error_dict=e_dict)
fixed saving settings on repositories inside groups, also fixes #187...
r1323
commit less models...
r1749 elif Repository.get_by_repo_name(repo_name_full):
#344 optional firstname lastname on user creation...
r1950 e_dict = {'repo_name': _('This repository '
fixed regresion made in previos commit, that introduced bug in handling regular repositories
r1324 'already exists')}
fixed saving settings on repositories inside groups, also fixes #187...
r1323 raise formencode.Invalid('', value, state,
error_dict=e_dict)
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
r1550
fixed saving settings on repositories inside groups, also fixes #187...
r1323 return value
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 return _ValidRepoName
added validation to repo groups to check for conflicting repository name fixes #337
r1898
#235 forking page repo group selection...
r1722 def ValidForkName(*args, **kwargs):
return ValidRepoName(*args, **kwargs)
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 def SlugifyName():
class _SlugifyName(formencode.validators.FancyValidator):
fixed saving settings on repositories inside groups, also fixes #187...
r1323
def to_python(self, value, state):
return repo_name_slug(value)
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 return _SlugifyName
fixed saving settings on repositories inside groups, also fixes #187...
r1323
added validation to repo groups to check for conflicting repository name fixes #337
r1898
added dump validation of cloneurl, it can still freeze if server will ask for auth.
r1261 def ValidCloneUri():
from rhodecode.lib.utils import make_ui
fixed issue with remote repos on git
r2053 def url_handler(repo_type, url, proto, ui=None):
if repo_type == 'hg':
from mercurial.httprepo import httprepository, httpsrepository
if proto == 'https':
httpsrepository(make_ui('db'), url).capabilities
elif proto == 'http':
httprepository(make_ui('db'), url).capabilities
elif repo_type == 'git':
#TODO: write a git url validator
pass
added dump validation of cloneurl, it can still freeze if server will ask for auth.
r1261 class _ValidCloneUri(formencode.validators.FancyValidator):
fixed http/s validation for clone_uri, and missing return value.
r1298
added dump validation of cloneurl, it can still freeze if server will ask for auth.
r1261 def to_python(self, value, state):
fixed issue with remote repos on git
r2053
repo_type = value.get('repo_type')
url = value.get('clone_uri')
e_dict = {'clone_uri': _('invalid clone url')}
if not url:
added dump validation of cloneurl, it can still freeze if server will ask for auth.
r1261 pass
fixed issue with remote repos on git
r2053 elif url.startswith('https'):
added dump validation of cloneurl, it can still freeze if server will ask for auth.
r1261 try:
fixed issue with remote repos on git
r2053 url_handler(repo_type, url, 'https', make_ui('db'))
#344 optional firstname lastname on user creation...
r1950 except Exception:
fixed http/s validation for clone_uri, and missing return value.
r1298 log.error(traceback.format_exc())
fixed issue with remote repos on git
r2053 raise formencode.Invalid('', value, state, error_dict=e_dict)
elif url.startswith('http'):
added dump validation of cloneurl, it can still freeze if server will ask for auth.
r1261 try:
fixed issue with remote repos on git
r2053 url_handler(repo_type, url, 'http', make_ui('db'))
#344 optional firstname lastname on user creation...
r1950 except Exception:
fixed http/s validation for clone_uri, and missing return value.
r1298 log.error(traceback.format_exc())
fixed issue with remote repos on git
r2053 raise formencode.Invalid('', value, state, error_dict=e_dict)
added dump validation of cloneurl, it can still freeze if server will ask for auth.
r1261 else:
fixed issue with remote repos on git
r2053 e_dict = {'clone_uri': _('Invalid clone url, provide a '
'valid clone http\s url')}
raise formencode.Invalid('', value, state, error_dict=e_dict)
fixed http/s validation for clone_uri, and missing return value.
r1298 return value
added dump validation of cloneurl, it can still freeze if server will ask for auth.
r1261
return _ValidCloneUri
added validation to repo groups to check for conflicting repository name fixes #337
r1898
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659 def ValidForkType(old_data):
class _ValidForkType(formencode.validators.FancyValidator):
def to_python(self, value, state):
if old_data['repo_type'] != value:
added dump validation of cloneurl, it can still freeze if server will ask for auth.
r1261 raise formencode.Invalid(_('Fork have to be the same '
'type as original'), value, state)
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659 return value
return _ValidForkType
added validation to repo groups to check for conflicting repository name fixes #337
r1898
#227 Initial version of repository groups permissions system...
r1982 def ValidPerms(type_='repo'):
if type_ == 'group':
EMPTY_PERM = 'group.none'
elif type_ == 'repo':
EMPTY_PERM = 'repository.none'
Code refactoring,models renames...
r629
#227 Initial version of repository groups permissions system...
r1982 class _ValidPerms(formencode.validators.FancyValidator):
messages = {
'perm_new_member_name':
_('This username or users group name is not valid')
}
def to_python(self, value, state):
perms_update = []
perms_new = []
# build a list of permission to update and new permission to create
for k, v in value.items():
# means new added member to permissions
if k.startswith('perm_new_member'):
new_perm = value.get('perm_new_member', False)
new_member = value.get('perm_new_member_name', False)
new_type = value.get('perm_new_member_type')
#56 hacking on forms, and model for users groups
r1013
#227 Initial version of repository groups permissions system...
r1982 if new_member and new_perm:
if (new_member, new_perm, new_type) not in perms_new:
perms_new.append((new_member, new_perm, new_type))
elif k.startswith('u_perm_') or k.startswith('g_perm_'):
member = k[7:]
t = {'u': 'user',
'g': 'users_group'
}[k[0]]
if member == 'default':
if value.get('private'):
# set none for default when updating to private repo
v = EMPTY_PERM
perms_update.append((member, v, t))
#56 added ajax removal of users groups,...
r1015
#227 Initial version of repository groups permissions system...
r1982 value['perms_updates'] = perms_update
value['perms_new'] = perms_new
#56 added assignments of users groups into repository
r1014
#227 Initial version of repository groups permissions system...
r1982 # update permissions
for k, v, t in perms_new:
try:
if t is 'user':
self.user_db = User.query()\
.filter(User.active == True)\
.filter(User.username == k).one()
if t is 'users_group':
self.user_db = UsersGroup.query()\
.filter(UsersGroup.users_group_active == True)\
.filter(UsersGroup.users_group_name == k).one()
#56 hacking on forms, and model for users groups
r1013
#227 Initial version of repository groups permissions system...
r1982 except Exception:
msg = self.message('perm_new_member_name',
state=State_obj)
raise formencode.Invalid(
msg, value, state, error_dict={'perm_new_member_name': msg}
)
return value
return _ValidPerms
Code refactoring,models renames...
r629
added validation to repo groups to check for conflicting repository name fixes #337
r1898
renamed project to rhodecode
r547 class ValidSettings(formencode.validators.FancyValidator):
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 def to_python(self, value, state):
fixes #298, ldap email addresses created by rhodecode automatically during first login didn't get converted to lower case, which lead to lookup failures and than wrong checks for uniqueness. Fixed that by putting a setter on db model column that will enforce converting to lowercase.
r1757 # settings form can't edit user
#344 optional firstname lastname on user creation...
r1950 if 'user' in value:
renamed project to rhodecode
r547 del['value']['user']
return value
Code refactoring,models renames...
r629
added validation to repo groups to check for conflicting repository name fixes #337
r1898
renamed project to rhodecode
r547 class ValidPath(formencode.validators.FancyValidator):
def to_python(self, value, state):
Hacking for git support,and new faster repo scan
r631
if not os.path.isdir(value):
Code refactoring,models renames...
r629 msg = _('This is not a valid path')
Hacking for git support,and new faster repo scan
r631 raise formencode.Invalid(msg, value, state,
#344 optional firstname lastname on user creation...
r1950 error_dict={'paths_root_path': msg})
Hacking for git support,and new faster repo scan
r631 return value
renamed project to rhodecode
r547
added validation to repo groups to check for conflicting repository name fixes #337
r1898
renamed project to rhodecode
r547 def UniqSystemEmail(old_data):
class _UniqSystemEmail(formencode.validators.FancyValidator):
def to_python(self, value, state):
fixes issue #78, ldap makes user validation caseInsensitive...
r741 value = value.lower()
fixes #376 Cannot edit user (using container auth)
r2072 if (old_data.get('email') or '').lower() != value:
fixes #298, ldap email addresses created by rhodecode automatically during first login didn't get converted to lower case, which lead to lookup failures and than wrong checks for uniqueness. Fixed that by putting a setter on db model column that will enforce converting to lowercase.
r1757 user = User.get_by_email(value, case_insensitive=True)
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 if user:
raise formencode.Invalid(
#344 optional firstname lastname on user creation...
r1950 _("This e-mail address is already taken"), value, state
)
renamed project to rhodecode
r547 return value
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 return _UniqSystemEmail
Code refactoring,models renames...
r629
added validation to repo groups to check for conflicting repository name fixes #337
r1898
renamed project to rhodecode
r547 class ValidSystemEmail(formencode.validators.FancyValidator):
def to_python(self, value, state):
fixes issue #78, ldap makes user validation caseInsensitive...
r741 value = value.lower()
fixes #298, ldap email addresses created by rhodecode automatically during first login didn't get converted to lower case, which lead to lookup failures and than wrong checks for uniqueness. Fixed that by putting a setter on db model column that will enforce converting to lowercase.
r1757 user = User.get_by_email(value, case_insensitive=True)
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 if user is None:
#344 optional firstname lastname on user creation...
r1950 raise formencode.Invalid(
_("This e-mail address doesn't exist."), value, state
)
Code refactoring,models renames...
r629
return value
renamed project to rhodecode
r547
added validation to repo groups to check for conflicting repository name fixes #337
r1898
implements #60, ldap configuration and authentication....
r705 class LdapLibValidator(formencode.validators.FancyValidator):
def to_python(self, value, state):
try:
import ldap
except ImportError:
raise LdapImportError
return value
added validation to repo groups to check for conflicting repository name fixes #337
r1898
Thayne Harbaugh
Improve LDAP authentication...
r991 class AttrLoginValidator(formencode.validators.FancyValidator):
fixes #77 and adds extendable base Dn with custom uid specification
r775
def to_python(self, value, state):
Thayne Harbaugh
Improve LDAP authentication...
r991 if not value or not isinstance(value, (str, unicode)):
#344 optional firstname lastname on user creation...
r1950 raise formencode.Invalid(
_("The LDAP Login attribute of the CN must be specified - "
"this is the name of the attribute that is equivalent "
"to 'username'"), value, state
)
fixes #77 and adds extendable base Dn with custom uid specification
r775
return value
#344 optional firstname lastname on user creation...
r1950
added validation to repo groups to check for conflicting repository name fixes #337
r1898 #==============================================================================
source code cleanup: remove trailing white space, normalize file endings
r1203 # FORMS
added validation to repo groups to check for conflicting repository name fixes #337
r1898 #==============================================================================
renamed project to rhodecode
r547 class LoginForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
username = UnicodeString(
#344 optional firstname lastname on user creation...
r1950 strip=True,
min=1,
not_empty=True,
messages={
'empty': _('Please enter a login'),
'tooShort': _('Enter a value %(min)i characters long or more')}
)
renamed project to rhodecode
r547
password = UnicodeString(
#344 optional firstname lastname on user creation...
r1950 strip=True,
min=3,
not_empty=True,
messages={
'empty': _('Please enter a password'),
'tooShort': _('Enter %(min)i characters or more')}
)
renamed project to rhodecode
r547
Matt Zuba
Remember Me option on login
r1802 remember = StringBoolean(if_missing=False)
auto white-space removal
r1818
renamed project to rhodecode
r547 chained_validators = [ValidAuth]
Code refactoring,models renames...
r629
added validation to repo groups to check for conflicting repository name fixes #337
r1898
renamed project to rhodecode
r547 def UserForm(edit=False, old_data={}):
class _UserForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
#78, fixed more reliable case insensitive searches
r742 username = All(UnicodeString(strip=True, min=1, not_empty=True),
ValidUsername(edit, old_data))
renamed project to rhodecode
r547 if edit:
fixes #69 password confirmation for register dialog....
r722 new_password = All(UnicodeString(strip=True, min=6, not_empty=False))
#344 optional firstname lastname on user creation...
r1950 password_confirmation = All(UnicodeString(strip=True, min=6,
not_empty=False))
renamed project to rhodecode
r547 admin = StringBoolean(if_missing=False)
else:
fixes #69 password confirmation for register dialog....
r722 password = All(UnicodeString(strip=True, min=6, not_empty=True))
#344 optional firstname lastname on user creation...
r1950 password_confirmation = All(UnicodeString(strip=True, min=6,
not_empty=False))
#235 forking page repo group selection...
r1722
renamed project to rhodecode
r547 active = StringBoolean(if_missing=False)
#344 optional firstname lastname on user creation...
r1950 name = UnicodeString(strip=True, min=1, not_empty=False)
lastname = UnicodeString(strip=True, min=1, not_empty=False)
renamed project to rhodecode
r547 email = All(Email(not_empty=True), UniqSystemEmail(old_data))
Code refactoring,models renames...
r629
implements #237 added password confirmation for my account and admin edit user.
r1597 chained_validators = [ValidPasswordsMatch, ValidPassword]
fixes #69 password confirmation for register dialog....
r722
renamed project to rhodecode
r547 return _UserForm
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959
#56 implemented users groups editing,...
r972 def UsersGroupForm(edit=False, old_data={}, available_members=[]):
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959 class _UsersGroupForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
users_group_name = All(UnicodeString(strip=True, min=1, not_empty=True),
ValidUsersGroup(edit, old_data))
users_group_active = StringBoolean(if_missing=False)
#56 implemented users groups editing,...
r972 if edit:
users_group_members = OneOf(available_members, hideList=False,
testValueList=True,
if_missing=None, not_empty=False)
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959 return _UsersGroupForm
added validation to repo groups to check for conflicting repository name fixes #337
r1898
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 def ReposGroupForm(edit=False, old_data={}, available_groups=[]):
class _ReposGroupForm(formencode.Schema):
allow_extra_fields = True
#227 Initial version of repository groups permissions system...
r1982 filter_extra_fields = False
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345
#47 implemented basic edition of groups
r1347 group_name = All(UnicodeString(strip=True, min=1, not_empty=True),
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 SlugifyName())
#47 implemented basic edition of groups
r1347 group_description = UnicodeString(strip=True, min=1,
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 not_empty=True)
#47 implemented basic edition of groups
r1347 group_parent_id = OneOf(available_groups, hideList=False,
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 testValueList=True,
if_missing=None, not_empty=False)
#227 Initial version of repository groups permissions system...
r1982 chained_validators = [ValidReposGroup(edit, old_data), ValidPerms('group')]
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345
return _ReposGroupForm
added validation to repo groups to check for conflicting repository name fixes #337
r1898
fixes #69 password confirmation for register dialog....
r722 def RegisterForm(edit=False, old_data={}):
class _RegisterForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
#78, fixed more reliable case insensitive searches
r742 username = All(ValidUsername(edit, old_data),
UnicodeString(strip=True, min=1, not_empty=True))
fixes #69 password confirmation for register dialog....
r722 password = All(UnicodeString(strip=True, min=6, not_empty=True))
password_confirmation = All(UnicodeString(strip=True, min=6, not_empty=True))
active = StringBoolean(if_missing=False)
#344 optional firstname lastname on user creation...
r1950 name = UnicodeString(strip=True, min=1, not_empty=False)
lastname = UnicodeString(strip=True, min=1, not_empty=False)
fixes #69 password confirmation for register dialog....
r722 email = All(Email(not_empty=True), UniqSystemEmail(old_data))
chained_validators = [ValidPasswordsMatch, ValidPassword]
return _RegisterForm
renamed project to rhodecode
r547
#344 optional firstname lastname on user creation...
r1950
renamed project to rhodecode
r547 def PasswordResetForm():
class _PasswordResetForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
Code refactoring,models renames...
r629 email = All(ValidSystemEmail(), Email(not_empty=True))
renamed project to rhodecode
r547 return _PasswordResetForm
#344 optional firstname lastname on user creation...
r1950
#109, added optional clone uri when creating repo....
r1112 def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
repo_groups=[]):
renamed project to rhodecode
r547 class _RepoForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
#78, fixed more reliable case insensitive searches
r742 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True),
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 SlugifyName())
fixed issue with remote repos on git
r2053 clone_uri = All(UnicodeString(strip=True, min=1, not_empty=False))
Changes for repo groups
r1159 repo_group = OneOf(repo_groups, hideList=True)
#109, added optional clone uri when creating repo....
r1112 repo_type = OneOf(supported_backends)
renamed project to rhodecode
r547 description = UnicodeString(strip=True, min=1, not_empty=True)
private = StringBoolean(if_missing=False)
fixes #62, added option to disable statistics for each repository
r810 enable_statistics = StringBoolean(if_missing=False)
implemented #84 downloads can be enabled/disabled per each repository from now.
r962 enable_downloads = StringBoolean(if_missing=False)
#109, added optional clone uri when creating repo....
r1112
renamed project to rhodecode
r547 if edit:
#56 added assignments of users groups into repository
r1014 #this is repo owner
fixed saving settings on repositories inside groups, also fixes #187...
r1323 user = All(UnicodeString(not_empty=True), ValidRepoUser)
Code refactoring,models renames...
r629
fixed issue with remote repos on git
r2053 chained_validators = [ValidCloneUri()(),
updated CONTRIBUTORS...
r2058 ValidRepoName(edit, old_data),
fixed issue with remote repos on git
r2053 ValidPerms()]
renamed project to rhodecode
r547 return _RepoForm
#344 optional firstname lastname on user creation...
r1950
#235 forking page repo group selection...
r1722 def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
repo_groups=[]):
renamed project to rhodecode
r547 class _RepoForkForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
#235 forking page repo group selection...
r1722 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True),
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 SlugifyName())
#235 forking page repo group selection...
r1722 repo_group = OneOf(repo_groups, hideList=True)
repo_type = All(ValidForkType(old_data), OneOf(supported_backends))
renamed project to rhodecode
r547 description = UnicodeString(strip=True, min=1, not_empty=True)
private = StringBoolean(if_missing=False)
#235 forking page repo group selection...
r1722 copy_permissions = StringBoolean(if_missing=False)
added option to do a checkout after cloning a repository
r1742 update_after_clone = StringBoolean(if_missing=False)
#235 forking page repo group selection...
r1722 fork_parent_id = UnicodeString()
chained_validators = [ValidForkName(edit, old_data)]
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366
renamed project to rhodecode
r547 return _RepoForkForm
#344 optional firstname lastname on user creation...
r1950
fixes #288...
r1594 def RepoSettingsForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
repo_groups=[]):
renamed project to rhodecode
r547 class _RepoForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
#78, fixed more reliable case insensitive searches
r742 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True),
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods....
r1345 SlugifyName())
renamed project to rhodecode
r547 description = UnicodeString(strip=True, min=1, not_empty=True)
fixes #288...
r1594 repo_group = OneOf(repo_groups, hideList=True)
renamed project to rhodecode
r547 private = StringBoolean(if_missing=False)
Code refactoring,models renames...
r629
#227 Initial version of repository groups permissions system...
r1982 chained_validators = [ValidRepoName(edit, old_data), ValidPerms(),
fixes #288...
r1594 ValidSettings]
renamed project to rhodecode
r547 return _RepoForm
def ApplicationSettingsForm():
class _ApplicationSettingsForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
renamed hg_app to rhodecode
r548 rhodecode_title = UnicodeString(strip=True, min=1, not_empty=True)
rhodecode_realm = UnicodeString(strip=True, min=1, not_empty=True)
fixes for #89 ga code
r891 rhodecode_ga_code = UnicodeString(strip=True, min=1, not_empty=False)
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 return _ApplicationSettingsForm
Code refactoring,models renames...
r629
#344 optional firstname lastname on user creation...
r1950
renamed project to rhodecode
r547 def ApplicationUiSettingsForm():
class _ApplicationUiSettingsForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
web_push_ssl = OneOf(['true', 'false'], if_missing='false')
paths_root_path = All(ValidPath(), UnicodeString(strip=True, min=1, not_empty=True))
hooks_changegroup_update = OneOf(['True', 'False'], if_missing=False)
hooks_changegroup_repo_size = OneOf(['True', 'False'], if_missing=False)
added option to enable/disable of logger hooks from admin panel....
r661 hooks_pretxnchangegroup_push_logger = OneOf(['True', 'False'], if_missing=False)
hooks_preoutgoing_pull_logger = OneOf(['True', 'False'], if_missing=False)
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 return _ApplicationUiSettingsForm
#344 optional firstname lastname on user creation...
r1950
renamed project to rhodecode
r547 def DefaultPermissionsForm(perms_choices, register_choices, create_choices):
class _DefaultPermissionsForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
implements #60, ldap configuration and authentication....
r705 overwrite_default = StringBoolean(if_missing=False)
#49 Enabled anonymous access for web interface controllable from permissions pannel
r673 anonymous = OneOf(['True', 'False'], if_missing=False)
renamed project to rhodecode
r547 default_perm = OneOf(perms_choices)
default_register = OneOf(register_choices)
default_create = OneOf(create_choices)
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 return _DefaultPermissionsForm
implements #60, ldap configuration and authentication....
r705
"Lorenzo M. Catucci"
Enable start_tls connection encryption.
r1290 def LdapSettingsForm(tls_reqcert_choices, search_scope_choices, tls_kind_choices):
implements #60, ldap configuration and authentication....
r705 class _LdapSettingsForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
pre_validators = [LdapLibValidator]
ldap_active = StringBoolean(if_missing=False)
ldap_host = UnicodeString(strip=True,)
ldap_port = Number(strip=True,)
"Lorenzo M. Catucci"
Enable start_tls connection encryption.
r1290 ldap_tls_kind = OneOf(tls_kind_choices)
Thayne Harbaugh
Improve LDAP authentication...
r991 ldap_tls_reqcert = OneOf(tls_reqcert_choices)
implements #60, ldap configuration and authentication....
r705 ldap_dn_user = UnicodeString(strip=True,)
ldap_dn_pass = UnicodeString(strip=True,)
Thayne Harbaugh
Improve LDAP authentication...
r991 ldap_base_dn = UnicodeString(strip=True,)
ldap_filter = UnicodeString(strip=True,)
ldap_search_scope = OneOf(search_scope_choices)
ldap_attr_login = All(AttrLoginValidator, UnicodeString(strip=True,))
ldap_attr_firstname = UnicodeString(strip=True,)
ldap_attr_lastname = UnicodeString(strip=True,)
ldap_attr_email = UnicodeString(strip=True,)
implements #60, ldap configuration and authentication....
r705
return _LdapSettingsForm