Mercurial > public > src > rhodecode
comparison pylons_app/model/forms.py @ 575:6d44d3862ec4
fixes #36, removed username, name, lastname, minimal length restrictions,
fixed branches/tags icons in changelog and made them active links
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 30 Sep 2010 12:44:06 +0200 |
parents | 74b9bed279ae |
children | 3a567e329fb6 |
comparison
equal
deleted
inserted
replaced
574:804a14e086dc | 575:6d44d3862ec4 |
---|---|
245 class LoginForm(formencode.Schema): | 245 class LoginForm(formencode.Schema): |
246 allow_extra_fields = True | 246 allow_extra_fields = True |
247 filter_extra_fields = True | 247 filter_extra_fields = True |
248 username = UnicodeString( | 248 username = UnicodeString( |
249 strip=True, | 249 strip=True, |
250 min=3, | 250 min=1, |
251 not_empty=True, | 251 not_empty=True, |
252 messages={ | 252 messages={ |
253 'empty':_('Please enter a login'), | 253 'empty':_('Please enter a login'), |
254 'tooShort':_('Enter a value %(min)i characters long or more')} | 254 'tooShort':_('Enter a value %(min)i characters long or more')} |
255 ) | 255 ) |
256 | 256 |
257 password = UnicodeString( | 257 password = UnicodeString( |
258 strip=True, | 258 strip=True, |
259 min=3, | 259 min=8, |
260 not_empty=True, | 260 not_empty=True, |
261 messages={ | 261 messages={ |
262 'empty':_('Please enter a password'), | 262 'empty':_('Please enter a password'), |
263 'tooShort':_('Enter a value %(min)i characters long or more')} | 263 'tooShort':_('Enter a value %(min)i characters long or more')} |
264 ) | 264 ) |
269 | 269 |
270 def UserForm(edit=False, old_data={}): | 270 def UserForm(edit=False, old_data={}): |
271 class _UserForm(formencode.Schema): | 271 class _UserForm(formencode.Schema): |
272 allow_extra_fields = True | 272 allow_extra_fields = True |
273 filter_extra_fields = True | 273 filter_extra_fields = True |
274 username = All(UnicodeString(strip=True, min=3, not_empty=True), ValidUsername(edit, old_data)) | 274 username = All(UnicodeString(strip=True, min=1, not_empty=True), ValidUsername(edit, old_data)) |
275 if edit: | 275 if edit: |
276 new_password = All(UnicodeString(strip=True, min=3, not_empty=False), ValidPassword) | 276 new_password = All(UnicodeString(strip=True, min=8, not_empty=False), ValidPassword) |
277 admin = StringBoolean(if_missing=False) | 277 admin = StringBoolean(if_missing=False) |
278 else: | 278 else: |
279 password = All(UnicodeString(strip=True, min=8, not_empty=True), ValidPassword) | 279 password = All(UnicodeString(strip=True, min=8, not_empty=True), ValidPassword) |
280 active = StringBoolean(if_missing=False) | 280 active = StringBoolean(if_missing=False) |
281 name = UnicodeString(strip=True, min=3, not_empty=True) | 281 name = UnicodeString(strip=True, min=1, not_empty=True) |
282 lastname = UnicodeString(strip=True, min=3, not_empty=True) | 282 lastname = UnicodeString(strip=True, min=1, not_empty=True) |
283 email = All(Email(not_empty=True), UniqSystemEmail(old_data)) | 283 email = All(Email(not_empty=True), UniqSystemEmail(old_data)) |
284 | 284 |
285 return _UserForm | 285 return _UserForm |
286 | 286 |
287 RegisterForm = UserForm | 287 RegisterForm = UserForm |
296 def RepoForm(edit=False, old_data={}): | 296 def RepoForm(edit=False, old_data={}): |
297 class _RepoForm(formencode.Schema): | 297 class _RepoForm(formencode.Schema): |
298 allow_extra_fields = True | 298 allow_extra_fields = True |
299 filter_extra_fields = False | 299 filter_extra_fields = False |
300 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit, old_data)) | 300 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit, old_data)) |
301 description = UnicodeString(strip=True, min=3, not_empty=True) | 301 description = UnicodeString(strip=True, min=1, not_empty=True) |
302 private = StringBoolean(if_missing=False) | 302 private = StringBoolean(if_missing=False) |
303 | 303 |
304 if edit: | 304 if edit: |
305 user = All(Int(not_empty=True), ValidRepoUser) | 305 user = All(Int(not_empty=True), ValidRepoUser) |
306 | 306 |
310 def RepoSettingsForm(edit=False, old_data={}): | 310 def RepoSettingsForm(edit=False, old_data={}): |
311 class _RepoForm(formencode.Schema): | 311 class _RepoForm(formencode.Schema): |
312 allow_extra_fields = True | 312 allow_extra_fields = True |
313 filter_extra_fields = False | 313 filter_extra_fields = False |
314 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit, old_data)) | 314 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit, old_data)) |
315 description = UnicodeString(strip=True, min=3, not_empty=True) | 315 description = UnicodeString(strip=True, min=1, not_empty=True) |
316 private = StringBoolean(if_missing=False) | 316 private = StringBoolean(if_missing=False) |
317 | 317 |
318 chained_validators = [ValidPerms, ValidSettings] | 318 chained_validators = [ValidPerms, ValidSettings] |
319 return _RepoForm | 319 return _RepoForm |
320 | 320 |
321 | 321 |
322 def ApplicationSettingsForm(): | 322 def ApplicationSettingsForm(): |
323 class _ApplicationSettingsForm(formencode.Schema): | 323 class _ApplicationSettingsForm(formencode.Schema): |
324 allow_extra_fields = True | 324 allow_extra_fields = True |
325 filter_extra_fields = False | 325 filter_extra_fields = False |
326 hg_app_title = UnicodeString(strip=True, min=3, not_empty=True) | 326 hg_app_title = UnicodeString(strip=True, min=1, not_empty=True) |
327 hg_app_realm = UnicodeString(strip=True, min=3, not_empty=True) | 327 hg_app_realm = UnicodeString(strip=True, min=1, not_empty=True) |
328 | 328 |
329 return _ApplicationSettingsForm | 329 return _ApplicationSettingsForm |
330 | 330 |
331 def ApplicationUiSettingsForm(): | 331 def ApplicationUiSettingsForm(): |
332 class _ApplicationUiSettingsForm(formencode.Schema): | 332 class _ApplicationUiSettingsForm(formencode.Schema): |
333 allow_extra_fields = True | 333 allow_extra_fields = True |
334 filter_extra_fields = False | 334 filter_extra_fields = False |
335 web_push_ssl = OneOf(['true', 'false'], if_missing='false') | 335 web_push_ssl = OneOf(['true', 'false'], if_missing='false') |
336 paths_root_path = All(ValidPath(), UnicodeString(strip=True, min=3, not_empty=True)) | 336 paths_root_path = All(ValidPath(), UnicodeString(strip=True, min=1, not_empty=True)) |
337 hooks_changegroup_update = OneOf(['True', 'False'], if_missing=False) | 337 hooks_changegroup_update = OneOf(['True', 'False'], if_missing=False) |
338 hooks_changegroup_repo_size = OneOf(['True', 'False'], if_missing=False) | 338 hooks_changegroup_repo_size = OneOf(['True', 'False'], if_missing=False) |
339 | 339 |
340 return _ApplicationUiSettingsForm | 340 return _ApplicationUiSettingsForm |
341 | 341 |