Files
@ 8eab81115660
Branch filter:
Location: kallithea/rhodecode/model/forms.py - annotation
8eab81115660
11.6 KiB
text/x-python
white space cleanup
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 6832ef664673 6832ef664673 6832ef664673 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 6832ef664673 1e757ac98988 56c2850a5b5f 56c2850a5b5f 56c2850a5b5f 1e757ac98988 56c2850a5b5f 1e757ac98988 56c2850a5b5f 4419551b2915 56c2850a5b5f 56c2850a5b5f 1e757ac98988 1e757ac98988 a7dfe823933a 1e757ac98988 1e757ac98988 1e757ac98988 4419551b2915 4ae17f819ee8 4ae17f819ee8 4ae17f819ee8 4ae17f819ee8 4419551b2915 4419551b2915 4ae17f819ee8 1e757ac98988 4419551b2915 e1c1ebbe7346 4ae17f819ee8 4ae17f819ee8 4ae17f819ee8 4419551b2915 4419551b2915 4ae17f819ee8 1e757ac98988 4419551b2915 cf51bbfb120e 4419551b2915 7e536d1af60d a7dfe823933a 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 4419551b2915 4419551b2915 1e757ac98988 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 1e757ac98988 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 e7eef7a1db6a 4419551b2915 4419551b2915 4419551b2915 4419551b2915 7e536d1af60d 4419551b2915 02bdf2f296ff 1e757ac98988 1e757ac98988 fff21c9b075c 2c8fd84935a4 fff21c9b075c fff21c9b075c fff21c9b075c fff21c9b075c 4419551b2915 4419551b2915 4419551b2915 4419551b2915 fff21c9b075c 4419551b2915 fff21c9b075c 2c8fd84935a4 4419551b2915 4419551b2915 4419551b2915 4419551b2915 2c8fd84935a4 fff21c9b075c fff21c9b075c a7dfe823933a 3bce31f026b8 3bce31f026b8 3bce31f026b8 87f0800abc7b 3bce31f026b8 4419551b2915 4419551b2915 4419551b2915 3bce31f026b8 4419551b2915 3bce31f026b8 3bce31f026b8 3bce31f026b8 4419551b2915 4419551b2915 3bce31f026b8 3bce31f026b8 3bce31f026b8 a7dfe823933a 02bdf2f296ff 02bdf2f296ff 02bdf2f296ff 02bdf2f296ff 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 02bdf2f296ff 4419551b2915 02bdf2f296ff 02bdf2f296ff 1e757ac98988 4ae17f819ee8 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 4419551b2915 1e757ac98988 1e757ac98988 4ae17f819ee8 6d0a7284949d 12fa0c19c42f 1e757ac98988 1e757ac98988 1e757ac98988 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 6d0a7284949d 1e757ac98988 6fdc3ff65fce 4419551b2915 7e536d1af60d 4419551b2915 4419551b2915 4419551b2915 1e757ac98988 1e757ac98988 4ae17f819ee8 12fa0c19c42f 12fa0c19c42f 1e757ac98988 1e757ac98988 1e757ac98988 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 9c0f5d558789 1e757ac98988 1e757ac98988 4ae17f819ee8 4419551b2915 4419551b2915 4419551b2915 1e757ac98988 1e757ac98988 1e757ac98988 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 4419551b2915 4419551b2915 4419551b2915 7e536d1af60d 1e757ac98988 7e536d1af60d 4ae17f819ee8 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 7e536d1af60d 1e757ac98988 1e757ac98988 4ae17f819ee8 1e757ac98988 1e757ac98988 1e757ac98988 1e757ac98988 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 7e536d1af60d 1e757ac98988 9e9f1b919c0c 9e9f1b919c0c 4419551b2915 4419551b2915 9e9f1b919c0c 9e9f1b919c0c 9e9f1b919c0c 3ea397063fc7 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 4419551b2915 9e9f1b919c0c 9e9f1b919c0c | """ 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.
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
<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())
"""
import logging
import formencode
from formencode import All
from pylons.i18n.translation import _
from rhodecode.model import validators as v
from rhodecode import BACKENDS
log = logging.getLogger(__name__)
class LoginForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
username = v.UnicodeString(
strip=True,
min=1,
not_empty=True,
messages={
'empty': _(u'Please enter a login'),
'tooShort': _(u'Enter a value %(min)i characters long or more')}
)
password = v.UnicodeString(
strip=False,
min=3,
not_empty=True,
messages={
'empty': _(u'Please enter a password'),
'tooShort': _(u'Enter %(min)i characters or more')}
)
remember = v.StringBoolean(if_missing=False)
chained_validators = [v.ValidAuth()]
def UserForm(edit=False, old_data={}):
class _UserForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
username = All(v.UnicodeString(strip=True, min=1, not_empty=True),
v.ValidUsername(edit, old_data))
if edit:
new_password = All(
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)
else:
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)
)
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))
chained_validators = [v.ValidPasswordsMatch()]
return _UserForm
def UsersGroupForm(edit=False, old_data={}, available_members=[]):
class _UsersGroupForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
users_group_name = All(
v.UnicodeString(strip=True, min=1, not_empty=True),
v.ValidUsersGroup(edit, old_data)
)
users_group_active = v.StringBoolean(if_missing=False)
if edit:
users_group_members = v.OneOf(
available_members, hideList=False, testValueList=True,
if_missing=None, not_empty=False
)
return _UsersGroupForm
def ReposGroupForm(edit=False, old_data={}, available_groups=[]):
class _ReposGroupForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
group_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
v.SlugifyName())
group_description = v.UnicodeString(strip=True, min=1,
not_empty=True)
group_parent_id = v.OneOf(available_groups, hideList=False,
testValueList=True,
if_missing=None, not_empty=False)
chained_validators = [v.ValidReposGroup(edit, old_data),
v.ValidPerms('group')]
return _ReposGroupForm
def RegisterForm(edit=False, old_data={}):
class _RegisterForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
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))
chained_validators = [v.ValidPasswordsMatch()]
return _RegisterForm
def PasswordResetForm():
class _PasswordResetForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
email = All(v.ValidSystemEmail(), v.Email(not_empty=True))
return _PasswordResetForm
def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
repo_groups=[], landing_revs=[]):
class _RepoForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
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)
if edit:
#this is repo owner
user = All(v.UnicodeString(not_empty=True), v.ValidRepoUser())
chained_validators = [v.ValidCloneUri(),
v.ValidRepoName(edit, old_data),
v.ValidPerms()]
return _RepoForm
def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
repo_groups=[]):
class _RepoForkForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
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)]
return _RepoForkForm
def RepoSettingsForm(edit=False, old_data={},
supported_backends=BACKENDS.keys(), repo_groups=[],
landing_revs=[]):
class _RepoForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
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()]
return _RepoForm
def ApplicationSettingsForm():
class _ApplicationSettingsForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
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)
return _ApplicationSettingsForm
def ApplicationUiSettingsForm():
class _ApplicationUiSettingsForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = False
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)
return _ApplicationUiSettingsForm
def DefaultPermissionsForm(perms_choices, register_choices, create_choices):
class _DefaultPermissionsForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
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)
return _DefaultPermissionsForm
def LdapSettingsForm(tls_reqcert_choices, search_scope_choices,
tls_kind_choices):
class _LdapSettingsForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
#pre_validators = [LdapLibValidator]
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,)
return _LdapSettingsForm
|