##// END OF EJS Templates
Sync test.ini with development.ini
Sync test.ini with development.ini

File last commit:

r2544:6ce3387b beta
r2558:ecdfa7a4 beta
Show More
forms.py
310 lines | 11.8 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 logging
import formencode
renamed project to rhodecode
r547 from formencode import All
ldap auth rewrite, moved split authfunc into two functions,...
r761
renamed project to rhodecode
r547 from pylons.i18n.translation import _
ldap auth rewrite, moved split authfunc into two functions,...
r761
Switched forms to new validators
r2467 from rhodecode.model import validators as v
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 class LoginForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
Switched forms to new validators
r2467 username = v.UnicodeString(
#344 optional firstname lastname on user creation...
r1950 strip=True,
min=1,
not_empty=True,
messages={
Switched forms to new validators
r2467 'empty': _(u'Please enter a login'),
'tooShort': _(u'Enter a value %(min)i characters long or more')}
#344 optional firstname lastname on user creation...
r1950 )
renamed project to rhodecode
r547
Switched forms to new validators
r2467 password = v.UnicodeString(
#419 don't strip passwords for login forms, make rhodecode more compatible with LDAP servers
r2181 strip=False,
#344 optional firstname lastname on user creation...
r1950 min=3,
not_empty=True,
messages={
Switched forms to new validators
r2467 'empty': _(u'Please enter a password'),
'tooShort': _(u'Enter %(min)i characters or more')}
#344 optional firstname lastname on user creation...
r1950 )
renamed project to rhodecode
r547
Switched forms to new validators
r2467 remember = v.StringBoolean(if_missing=False)
auto white-space removal
r1818
Switched forms to new validators
r2467 chained_validators = [v.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
Switched forms to new validators
r2467 username = All(v.UnicodeString(strip=True, min=1, not_empty=True),
v.ValidUsername(edit, old_data))
renamed project to rhodecode
r547 if edit:
Switched forms to new validators
r2467 new_password = All(
Renamed name to firstname in forms...
r2544 v.ValidPassword(),
Switched forms to new validators
r2467 v.UnicodeString(strip=False, min=6, not_empty=False)
)
password_confirmation = All(
v.ValidPassword(),
v.UnicodeString(strip=False, min=6, not_empty=False),
)
admin = v.StringBoolean(if_missing=False)
renamed project to rhodecode
r547 else:
Switched forms to new validators
r2467 password = All(
v.ValidPassword(),
v.UnicodeString(strip=False, min=6, not_empty=True)
)
password_confirmation = All(
v.ValidPassword(),
v.UnicodeString(strip=False, min=6, not_empty=False)
)
#235 forking page repo group selection...
r1722
Switched forms to new validators
r2467 active = v.StringBoolean(if_missing=False)
Renamed name to firstname in forms...
r2544 firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
Switched forms to new validators
r2467 lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
email = All(v.Email(not_empty=True), v.UniqSystemEmail(old_data))
Code refactoring,models renames...
r629
Switched forms to new validators
r2467 chained_validators = [v.ValidPasswordsMatch()]
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
Switched forms to new validators
r2467 users_group_name = All(
v.UnicodeString(strip=True, min=1, not_empty=True),
v.ValidUsersGroup(edit, old_data)
)
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959
Switched forms to new validators
r2467 users_group_active = v.StringBoolean(if_missing=False)
#56 fixed found bugs, implemented adding of new group + forms+validators...
r959
#56 implemented users groups editing,...
r972 if edit:
Switched forms to new validators
r2467 users_group_members = v.OneOf(
available_members, hideList=False, testValueList=True,
if_missing=None, not_empty=False
)
#56 implemented users groups editing,...
r972
#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
Switched forms to new validators
r2467 group_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
v.SlugifyName())
group_description = v.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)
Switched forms to new validators
r2467 group_parent_id = v.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)
Switched forms to new validators
r2467 chained_validators = [v.ValidReposGroup(edit, old_data),
v.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
Switched forms to new validators
r2467 username = All(
v.ValidUsername(edit, old_data),
v.UnicodeString(strip=True, min=1, not_empty=True)
)
password = All(
v.ValidPassword(),
v.UnicodeString(strip=False, min=6, not_empty=True)
)
password_confirmation = All(
v.ValidPassword(),
v.UnicodeString(strip=False, min=6, not_empty=True)
)
active = v.StringBoolean(if_missing=False)
name = v.UnicodeString(strip=True, min=1, not_empty=False)
lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
email = All(v.Email(not_empty=True), v.UniqSystemEmail(old_data))
fixes #69 password confirmation for register dialog....
r722
Switched forms to new validators
r2467 chained_validators = [v.ValidPasswordsMatch()]
fixes #69 password confirmation for register dialog....
r722
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
Switched forms to new validators
r2467 email = All(v.ValidSystemEmail(), v.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(),
validating choices for landing_rev
r2460 repo_groups=[], landing_revs=[]):
renamed project to rhodecode
r547 class _RepoForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
Switched forms to new validators
r2467 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
v.SlugifyName())
clone_uri = All(v.UnicodeString(strip=True, min=1, not_empty=False))
repo_group = v.OneOf(repo_groups, hideList=True)
repo_type = v.OneOf(supported_backends)
description = v.UnicodeString(strip=True, min=1, not_empty=False)
private = v.StringBoolean(if_missing=False)
enable_statistics = v.StringBoolean(if_missing=False)
enable_downloads = v.StringBoolean(if_missing=False)
landing_rev = v.OneOf(landing_revs, hideList=True)
#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
Switched forms to new validators
r2467 user = All(v.UnicodeString(not_empty=True), v.ValidRepoUser())
Code refactoring,models renames...
r629
Switched forms to new validators
r2467 chained_validators = [v.ValidCloneUri(),
v.ValidRepoName(edit, old_data),
v.ValidPerms()]
renamed project to rhodecode
r547 return _RepoForm
#344 optional firstname lastname on user creation...
r1950
validating choices for landing_rev
r2460 def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
added landing revision into fork create form
r2485 repo_groups=[], landing_revs=[]):
renamed project to rhodecode
r547 class _RepoForkForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
Switched forms to new validators
r2467 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
v.SlugifyName())
repo_group = v.OneOf(repo_groups, hideList=True)
repo_type = All(v.ValidForkType(old_data), v.OneOf(supported_backends))
description = v.UnicodeString(strip=True, min=1, not_empty=True)
private = v.StringBoolean(if_missing=False)
copy_permissions = v.StringBoolean(if_missing=False)
update_after_clone = v.StringBoolean(if_missing=False)
fork_parent_id = v.UnicodeString()
chained_validators = [v.ValidForkName(edit, old_data)]
added landing revision into fork create form
r2485 landing_rev = v.OneOf(landing_revs, hideList=True)
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
Switched forms to new validators
r2467 def RepoSettingsForm(edit=False, old_data={},
supported_backends=BACKENDS.keys(), repo_groups=[],
landing_revs=[]):
renamed project to rhodecode
r547 class _RepoForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
Switched forms to new validators
r2467 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
v.SlugifyName())
description = v.UnicodeString(strip=True, min=1, not_empty=True)
repo_group = v.OneOf(repo_groups, hideList=True)
private = v.StringBoolean(if_missing=False)
landing_rev = v.OneOf(landing_revs, hideList=True)
chained_validators = [v.ValidRepoName(edit, old_data), v.ValidPerms(),
v.ValidSettings()]
renamed project to rhodecode
r547 return _RepoForm
def ApplicationSettingsForm():
class _ApplicationSettingsForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
Switched forms to new validators
r2467 rhodecode_title = v.UnicodeString(strip=True, min=1, not_empty=True)
rhodecode_realm = v.UnicodeString(strip=True, min=1, not_empty=True)
rhodecode_ga_code = v.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
Switched forms to new validators
r2467 web_push_ssl = v.OneOf(['true', 'false'], if_missing='false')
paths_root_path = All(
v.ValidPath(),
v.UnicodeString(strip=True, min=1, not_empty=True)
)
hooks_changegroup_update = v.OneOf(['True', 'False'],
if_missing=False)
hooks_changegroup_repo_size = v.OneOf(['True', 'False'],
if_missing=False)
hooks_changegroup_push_logger = v.OneOf(['True', 'False'],
if_missing=False)
hooks_preoutgoing_pull_logger = v.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
Switched forms to new validators
r2467 overwrite_default = v.StringBoolean(if_missing=False)
anonymous = v.OneOf(['True', 'False'], if_missing=False)
default_perm = v.OneOf(perms_choices)
default_register = v.OneOf(register_choices)
default_create = v.OneOf(create_choices)
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 return _DefaultPermissionsForm
implements #60, ldap configuration and authentication....
r705
Switched forms to new validators
r2467 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
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
r2193 #pre_validators = [LdapLibValidator]
Switched forms to new validators
r2467 ldap_active = v.StringBoolean(if_missing=False)
ldap_host = v.UnicodeString(strip=True,)
ldap_port = v.Number(strip=True,)
ldap_tls_kind = v.OneOf(tls_kind_choices)
ldap_tls_reqcert = v.OneOf(tls_reqcert_choices)
ldap_dn_user = v.UnicodeString(strip=True,)
ldap_dn_pass = v.UnicodeString(strip=True,)
ldap_base_dn = v.UnicodeString(strip=True,)
ldap_filter = v.UnicodeString(strip=True,)
ldap_search_scope = v.OneOf(search_scope_choices)
ldap_attr_login = All(
v.AttrLoginValidator(),
v.UnicodeString(strip=True,)
)
ldap_attr_firstname = v.UnicodeString(strip=True,)
ldap_attr_lastname = v.UnicodeString(strip=True,)
ldap_attr_email = v.UnicodeString(strip=True,)
implements #60, ldap configuration and authentication....
r705
return _LdapSettingsForm
Added validation into user email map
r2479
def UserExtraEmailForm():
class _UserExtraEmailForm(formencode.Schema):
email = All(v.UniqSystemEmail(), v.Email)
User active flag should be default to True
r2480 return _UserExtraEmailForm