##// END OF EJS Templates
emails: fixed validation of emails with whitespace in them....
marcink -
r2256:69afdf58 stable
parent child Browse files
Show More
@@ -1,570 +1,570 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2010-2017 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 """
22 22 this is forms validation classes
23 23 http://formencode.org/module-formencode.validators.html
24 24 for list off all availible validators
25 25
26 26 we can create our own validators
27 27
28 28 The table below outlines the options which can be used in a schema in addition to the validators themselves
29 29 pre_validators [] These validators will be applied before the schema
30 30 chained_validators [] These validators will be applied after the schema
31 31 allow_extra_fields False If True, then it is not an error when keys that aren't associated with a validator are present
32 32 filter_extra_fields False If True, then keys that aren't associated with a validator are removed
33 33 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.
34 34 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
35 35
36 36
37 37 <name> = formencode.validators.<name of validator>
38 38 <name> must equal form name
39 39 list=[1,2,3,4,5]
40 40 for SELECT use formencode.All(OneOf(list), Int())
41 41
42 42 """
43 43
44 44 import deform
45 45 import logging
46 46 import formencode
47 47
48 48 from pkg_resources import resource_filename
49 49 from formencode import All, Pipe
50 50
51 51 from pylons.i18n.translation import _
52 52 from pyramid.threadlocal import get_current_request
53 53
54 54 from rhodecode import BACKENDS
55 55 from rhodecode.lib import helpers
56 56 from rhodecode.model import validators as v
57 57
58 58 log = logging.getLogger(__name__)
59 59
60 60
61 61 deform_templates = resource_filename('deform', 'templates')
62 62 rhodecode_templates = resource_filename('rhodecode', 'templates/forms')
63 63 search_path = (rhodecode_templates, deform_templates)
64 64
65 65
66 66 class RhodecodeFormZPTRendererFactory(deform.ZPTRendererFactory):
67 67 """ Subclass of ZPTRendererFactory to add rhodecode context variables """
68 68 def __call__(self, template_name, **kw):
69 69 kw['h'] = helpers
70 70 kw['request'] = get_current_request()
71 71 return self.load(template_name)(**kw)
72 72
73 73
74 74 form_renderer = RhodecodeFormZPTRendererFactory(search_path)
75 75 deform.Form.set_default_renderer(form_renderer)
76 76
77 77
78 78 def LoginForm():
79 79 class _LoginForm(formencode.Schema):
80 80 allow_extra_fields = True
81 81 filter_extra_fields = True
82 82 username = v.UnicodeString(
83 83 strip=True,
84 84 min=1,
85 85 not_empty=True,
86 86 messages={
87 87 'empty': _(u'Please enter a login'),
88 88 'tooShort': _(u'Enter a value %(min)i characters long or more')
89 89 }
90 90 )
91 91
92 92 password = v.UnicodeString(
93 93 strip=False,
94 94 min=3,
95 95 max=72,
96 96 not_empty=True,
97 97 messages={
98 98 'empty': _(u'Please enter a password'),
99 99 'tooShort': _(u'Enter %(min)i characters or more')}
100 100 )
101 101
102 102 remember = v.StringBoolean(if_missing=False)
103 103
104 104 chained_validators = [v.ValidAuth()]
105 105 return _LoginForm
106 106
107 107
108 108 def UserForm(edit=False, available_languages=[], old_data={}):
109 109 class _UserForm(formencode.Schema):
110 110 allow_extra_fields = True
111 111 filter_extra_fields = True
112 112 username = All(v.UnicodeString(strip=True, min=1, not_empty=True),
113 113 v.ValidUsername(edit, old_data))
114 114 if edit:
115 115 new_password = All(
116 116 v.ValidPassword(),
117 117 v.UnicodeString(strip=False, min=6, max=72, not_empty=False)
118 118 )
119 119 password_confirmation = All(
120 120 v.ValidPassword(),
121 121 v.UnicodeString(strip=False, min=6, max=72, not_empty=False),
122 122 )
123 123 admin = v.StringBoolean(if_missing=False)
124 124 else:
125 125 password = All(
126 126 v.ValidPassword(),
127 127 v.UnicodeString(strip=False, min=6, max=72, not_empty=True)
128 128 )
129 129 password_confirmation = All(
130 130 v.ValidPassword(),
131 131 v.UnicodeString(strip=False, min=6, max=72, not_empty=False)
132 132 )
133 133
134 134 password_change = v.StringBoolean(if_missing=False)
135 135 create_repo_group = v.StringBoolean(if_missing=False)
136 136
137 137 active = v.StringBoolean(if_missing=False)
138 138 firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
139 139 lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
140 email = All(v.Email(not_empty=True), v.UniqSystemEmail(old_data))
140 email = All(v.UniqSystemEmail(old_data), v.Email(not_empty=True))
141 141 extern_name = v.UnicodeString(strip=True)
142 142 extern_type = v.UnicodeString(strip=True)
143 143 language = v.OneOf(available_languages, hideList=False,
144 144 testValueList=True, if_missing=None)
145 145 chained_validators = [v.ValidPasswordsMatch()]
146 146 return _UserForm
147 147
148 148
149 149 def UserGroupForm(edit=False, old_data=None, allow_disabled=False):
150 150 old_data = old_data or {}
151 151
152 152 class _UserGroupForm(formencode.Schema):
153 153 allow_extra_fields = True
154 154 filter_extra_fields = True
155 155
156 156 users_group_name = All(
157 157 v.UnicodeString(strip=True, min=1, not_empty=True),
158 158 v.ValidUserGroup(edit, old_data)
159 159 )
160 160 user_group_description = v.UnicodeString(strip=True, min=1,
161 161 not_empty=False)
162 162
163 163 users_group_active = v.StringBoolean(if_missing=False)
164 164
165 165 if edit:
166 166 # this is user group owner
167 167 user = All(
168 168 v.UnicodeString(not_empty=True),
169 169 v.ValidRepoUser(allow_disabled))
170 170 return _UserGroupForm
171 171
172 172
173 173 def RepoGroupForm(edit=False, old_data=None, available_groups=None,
174 174 can_create_in_root=False, allow_disabled=False):
175 175 old_data = old_data or {}
176 176 available_groups = available_groups or []
177 177
178 178 class _RepoGroupForm(formencode.Schema):
179 179 allow_extra_fields = True
180 180 filter_extra_fields = False
181 181
182 182 group_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
183 183 v.SlugifyName(),)
184 184 group_description = v.UnicodeString(strip=True, min=1,
185 185 not_empty=False)
186 186 group_copy_permissions = v.StringBoolean(if_missing=False)
187 187
188 188 group_parent_id = v.OneOf(available_groups, hideList=False,
189 189 testValueList=True, not_empty=True)
190 190 enable_locking = v.StringBoolean(if_missing=False)
191 191 chained_validators = [
192 192 v.ValidRepoGroup(edit, old_data, can_create_in_root)]
193 193
194 194 if edit:
195 195 # this is repo group owner
196 196 user = All(
197 197 v.UnicodeString(not_empty=True),
198 198 v.ValidRepoUser(allow_disabled))
199 199
200 200 return _RepoGroupForm
201 201
202 202
203 203 def RegisterForm(edit=False, old_data={}):
204 204 class _RegisterForm(formencode.Schema):
205 205 allow_extra_fields = True
206 206 filter_extra_fields = True
207 207 username = All(
208 208 v.ValidUsername(edit, old_data),
209 209 v.UnicodeString(strip=True, min=1, not_empty=True)
210 210 )
211 211 password = All(
212 212 v.ValidPassword(),
213 213 v.UnicodeString(strip=False, min=6, max=72, not_empty=True)
214 214 )
215 215 password_confirmation = All(
216 216 v.ValidPassword(),
217 217 v.UnicodeString(strip=False, min=6, max=72, not_empty=True)
218 218 )
219 219 active = v.StringBoolean(if_missing=False)
220 220 firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
221 221 lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
222 email = All(v.Email(not_empty=True), v.UniqSystemEmail(old_data))
222 email = All(v.UniqSystemEmail(old_data), v.Email(not_empty=True))
223 223
224 224 chained_validators = [v.ValidPasswordsMatch()]
225 225
226 226 return _RegisterForm
227 227
228 228
229 229 def PasswordResetForm():
230 230 class _PasswordResetForm(formencode.Schema):
231 231 allow_extra_fields = True
232 232 filter_extra_fields = True
233 233 email = All(v.ValidSystemEmail(), v.Email(not_empty=True))
234 234 return _PasswordResetForm
235 235
236 236
237 237 def RepoForm(edit=False, old_data=None, repo_groups=None, landing_revs=None,
238 238 allow_disabled=False):
239 239 old_data = old_data or {}
240 240 repo_groups = repo_groups or []
241 241 landing_revs = landing_revs or []
242 242 supported_backends = BACKENDS.keys()
243 243
244 244 class _RepoForm(formencode.Schema):
245 245 allow_extra_fields = True
246 246 filter_extra_fields = False
247 247 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
248 248 v.SlugifyName(), v.CannotHaveGitSuffix())
249 249 repo_group = All(v.CanWriteGroup(old_data),
250 250 v.OneOf(repo_groups, hideList=True))
251 251 repo_type = v.OneOf(supported_backends, required=False,
252 252 if_missing=old_data.get('repo_type'))
253 253 repo_description = v.UnicodeString(strip=True, min=1, not_empty=False)
254 254 repo_private = v.StringBoolean(if_missing=False)
255 255 repo_landing_rev = v.OneOf(landing_revs, hideList=True)
256 256 repo_copy_permissions = v.StringBoolean(if_missing=False)
257 257 clone_uri = All(v.UnicodeString(strip=True, min=1, not_empty=False))
258 258
259 259 repo_enable_statistics = v.StringBoolean(if_missing=False)
260 260 repo_enable_downloads = v.StringBoolean(if_missing=False)
261 261 repo_enable_locking = v.StringBoolean(if_missing=False)
262 262
263 263 if edit:
264 264 # this is repo owner
265 265 user = All(
266 266 v.UnicodeString(not_empty=True),
267 267 v.ValidRepoUser(allow_disabled))
268 268 clone_uri_change = v.UnicodeString(
269 269 not_empty=False, if_missing=v.Missing)
270 270
271 271 chained_validators = [v.ValidCloneUri(),
272 272 v.ValidRepoName(edit, old_data)]
273 273 return _RepoForm
274 274
275 275
276 276 def RepoPermsForm():
277 277 class _RepoPermsForm(formencode.Schema):
278 278 allow_extra_fields = True
279 279 filter_extra_fields = False
280 280 chained_validators = [v.ValidPerms(type_='repo')]
281 281 return _RepoPermsForm
282 282
283 283
284 284 def RepoGroupPermsForm(valid_recursive_choices):
285 285 class _RepoGroupPermsForm(formencode.Schema):
286 286 allow_extra_fields = True
287 287 filter_extra_fields = False
288 288 recursive = v.OneOf(valid_recursive_choices)
289 289 chained_validators = [v.ValidPerms(type_='repo_group')]
290 290 return _RepoGroupPermsForm
291 291
292 292
293 293 def UserGroupPermsForm():
294 294 class _UserPermsForm(formencode.Schema):
295 295 allow_extra_fields = True
296 296 filter_extra_fields = False
297 297 chained_validators = [v.ValidPerms(type_='user_group')]
298 298 return _UserPermsForm
299 299
300 300
301 301 def RepoFieldForm():
302 302 class _RepoFieldForm(formencode.Schema):
303 303 filter_extra_fields = True
304 304 allow_extra_fields = True
305 305
306 306 new_field_key = All(v.FieldKey(),
307 307 v.UnicodeString(strip=True, min=3, not_empty=True))
308 308 new_field_value = v.UnicodeString(not_empty=False, if_missing=u'')
309 309 new_field_type = v.OneOf(['str', 'unicode', 'list', 'tuple'],
310 310 if_missing='str')
311 311 new_field_label = v.UnicodeString(not_empty=False)
312 312 new_field_desc = v.UnicodeString(not_empty=False)
313 313
314 314 return _RepoFieldForm
315 315
316 316
317 317 def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
318 318 repo_groups=[], landing_revs=[]):
319 319 class _RepoForkForm(formencode.Schema):
320 320 allow_extra_fields = True
321 321 filter_extra_fields = False
322 322 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
323 323 v.SlugifyName())
324 324 repo_group = All(v.CanWriteGroup(),
325 325 v.OneOf(repo_groups, hideList=True))
326 326 repo_type = All(v.ValidForkType(old_data), v.OneOf(supported_backends))
327 327 description = v.UnicodeString(strip=True, min=1, not_empty=True)
328 328 private = v.StringBoolean(if_missing=False)
329 329 copy_permissions = v.StringBoolean(if_missing=False)
330 330 fork_parent_id = v.UnicodeString()
331 331 chained_validators = [v.ValidForkName(edit, old_data)]
332 332 landing_rev = v.OneOf(landing_revs, hideList=True)
333 333
334 334 return _RepoForkForm
335 335
336 336
337 337 def ApplicationSettingsForm():
338 338 class _ApplicationSettingsForm(formencode.Schema):
339 339 allow_extra_fields = True
340 340 filter_extra_fields = False
341 341 rhodecode_title = v.UnicodeString(strip=True, max=40, not_empty=False)
342 342 rhodecode_realm = v.UnicodeString(strip=True, min=1, not_empty=True)
343 343 rhodecode_pre_code = v.UnicodeString(strip=True, min=1, not_empty=False)
344 344 rhodecode_post_code = v.UnicodeString(strip=True, min=1, not_empty=False)
345 345 rhodecode_captcha_public_key = v.UnicodeString(strip=True, min=1, not_empty=False)
346 346 rhodecode_captcha_private_key = v.UnicodeString(strip=True, min=1, not_empty=False)
347 347 rhodecode_create_personal_repo_group = v.StringBoolean(if_missing=False)
348 348 rhodecode_personal_repo_group_pattern = v.UnicodeString(strip=True, min=1, not_empty=False)
349 349
350 350 return _ApplicationSettingsForm
351 351
352 352
353 353 def ApplicationVisualisationForm():
354 354 class _ApplicationVisualisationForm(formencode.Schema):
355 355 allow_extra_fields = True
356 356 filter_extra_fields = False
357 357 rhodecode_show_public_icon = v.StringBoolean(if_missing=False)
358 358 rhodecode_show_private_icon = v.StringBoolean(if_missing=False)
359 359 rhodecode_stylify_metatags = v.StringBoolean(if_missing=False)
360 360
361 361 rhodecode_repository_fields = v.StringBoolean(if_missing=False)
362 362 rhodecode_lightweight_journal = v.StringBoolean(if_missing=False)
363 363 rhodecode_dashboard_items = v.Int(min=5, not_empty=True)
364 364 rhodecode_admin_grid_items = v.Int(min=5, not_empty=True)
365 365 rhodecode_show_version = v.StringBoolean(if_missing=False)
366 366 rhodecode_use_gravatar = v.StringBoolean(if_missing=False)
367 367 rhodecode_markup_renderer = v.OneOf(['markdown', 'rst'])
368 368 rhodecode_gravatar_url = v.UnicodeString(min=3)
369 369 rhodecode_clone_uri_tmpl = v.UnicodeString(min=3)
370 370 rhodecode_support_url = v.UnicodeString()
371 371 rhodecode_show_revision_number = v.StringBoolean(if_missing=False)
372 372 rhodecode_show_sha_length = v.Int(min=4, not_empty=True)
373 373
374 374 return _ApplicationVisualisationForm
375 375
376 376
377 377 class _BaseVcsSettingsForm(formencode.Schema):
378 378 allow_extra_fields = True
379 379 filter_extra_fields = False
380 380 hooks_changegroup_repo_size = v.StringBoolean(if_missing=False)
381 381 hooks_changegroup_push_logger = v.StringBoolean(if_missing=False)
382 382 hooks_outgoing_pull_logger = v.StringBoolean(if_missing=False)
383 383
384 384 # PR/Code-review
385 385 rhodecode_pr_merge_enabled = v.StringBoolean(if_missing=False)
386 386 rhodecode_use_outdated_comments = v.StringBoolean(if_missing=False)
387 387
388 388 # hg
389 389 extensions_largefiles = v.StringBoolean(if_missing=False)
390 390 extensions_evolve = v.StringBoolean(if_missing=False)
391 391 phases_publish = v.StringBoolean(if_missing=False)
392 392
393 393 rhodecode_hg_use_rebase_for_merging = v.StringBoolean(if_missing=False)
394 394 rhodecode_hg_close_branch_before_merging = v.StringBoolean(if_missing=False)
395 395
396 396 # git
397 397 vcs_git_lfs_enabled = v.StringBoolean(if_missing=False)
398 398 rhodecode_git_use_rebase_for_merging = v.StringBoolean(if_missing=False)
399 399 rhodecode_git_close_branch_before_merging = v.StringBoolean(if_missing=False)
400 400
401 401 # svn
402 402 vcs_svn_proxy_http_requests_enabled = v.StringBoolean(if_missing=False)
403 403 vcs_svn_proxy_http_server_url = v.UnicodeString(strip=True, if_missing=None)
404 404
405 405
406 406 def ApplicationUiSettingsForm():
407 407 class _ApplicationUiSettingsForm(_BaseVcsSettingsForm):
408 408 web_push_ssl = v.StringBoolean(if_missing=False)
409 409 paths_root_path = All(
410 410 v.ValidPath(),
411 411 v.UnicodeString(strip=True, min=1, not_empty=True)
412 412 )
413 413 largefiles_usercache = All(
414 414 v.ValidPath(),
415 415 v.UnicodeString(strip=True, min=2, not_empty=True))
416 416 vcs_git_lfs_store_location = All(
417 417 v.ValidPath(),
418 418 v.UnicodeString(strip=True, min=2, not_empty=True))
419 419 extensions_hgsubversion = v.StringBoolean(if_missing=False)
420 420 extensions_hggit = v.StringBoolean(if_missing=False)
421 421 new_svn_branch = v.ValidSvnPattern(section='vcs_svn_branch')
422 422 new_svn_tag = v.ValidSvnPattern(section='vcs_svn_tag')
423 423
424 424 return _ApplicationUiSettingsForm
425 425
426 426
427 427 def RepoVcsSettingsForm(repo_name):
428 428 class _RepoVcsSettingsForm(_BaseVcsSettingsForm):
429 429 inherit_global_settings = v.StringBoolean(if_missing=False)
430 430 new_svn_branch = v.ValidSvnPattern(
431 431 section='vcs_svn_branch', repo_name=repo_name)
432 432 new_svn_tag = v.ValidSvnPattern(
433 433 section='vcs_svn_tag', repo_name=repo_name)
434 434
435 435 return _RepoVcsSettingsForm
436 436
437 437
438 438 def LabsSettingsForm():
439 439 class _LabSettingsForm(formencode.Schema):
440 440 allow_extra_fields = True
441 441 filter_extra_fields = False
442 442
443 443 return _LabSettingsForm
444 444
445 445
446 446 def ApplicationPermissionsForm(
447 447 register_choices, password_reset_choices, extern_activate_choices):
448 448 class _DefaultPermissionsForm(formencode.Schema):
449 449 allow_extra_fields = True
450 450 filter_extra_fields = True
451 451
452 452 anonymous = v.StringBoolean(if_missing=False)
453 453 default_register = v.OneOf(register_choices)
454 454 default_register_message = v.UnicodeString()
455 455 default_password_reset = v.OneOf(password_reset_choices)
456 456 default_extern_activate = v.OneOf(extern_activate_choices)
457 457
458 458 return _DefaultPermissionsForm
459 459
460 460
461 461 def ObjectPermissionsForm(repo_perms_choices, group_perms_choices,
462 462 user_group_perms_choices):
463 463 class _ObjectPermissionsForm(formencode.Schema):
464 464 allow_extra_fields = True
465 465 filter_extra_fields = True
466 466 overwrite_default_repo = v.StringBoolean(if_missing=False)
467 467 overwrite_default_group = v.StringBoolean(if_missing=False)
468 468 overwrite_default_user_group = v.StringBoolean(if_missing=False)
469 469 default_repo_perm = v.OneOf(repo_perms_choices)
470 470 default_group_perm = v.OneOf(group_perms_choices)
471 471 default_user_group_perm = v.OneOf(user_group_perms_choices)
472 472
473 473 return _ObjectPermissionsForm
474 474
475 475
476 476 def UserPermissionsForm(create_choices, create_on_write_choices,
477 477 repo_group_create_choices, user_group_create_choices,
478 478 fork_choices, inherit_default_permissions_choices):
479 479 class _DefaultPermissionsForm(formencode.Schema):
480 480 allow_extra_fields = True
481 481 filter_extra_fields = True
482 482
483 483 anonymous = v.StringBoolean(if_missing=False)
484 484
485 485 default_repo_create = v.OneOf(create_choices)
486 486 default_repo_create_on_write = v.OneOf(create_on_write_choices)
487 487 default_user_group_create = v.OneOf(user_group_create_choices)
488 488 default_repo_group_create = v.OneOf(repo_group_create_choices)
489 489 default_fork_create = v.OneOf(fork_choices)
490 490 default_inherit_default_permissions = v.OneOf(inherit_default_permissions_choices)
491 491
492 492 return _DefaultPermissionsForm
493 493
494 494
495 495 def UserIndividualPermissionsForm():
496 496 class _DefaultPermissionsForm(formencode.Schema):
497 497 allow_extra_fields = True
498 498 filter_extra_fields = True
499 499
500 500 inherit_default_permissions = v.StringBoolean(if_missing=False)
501 501
502 502 return _DefaultPermissionsForm
503 503
504 504
505 505 def DefaultsForm(edit=False, old_data={}, supported_backends=BACKENDS.keys()):
506 506 class _DefaultsForm(formencode.Schema):
507 507 allow_extra_fields = True
508 508 filter_extra_fields = True
509 509 default_repo_type = v.OneOf(supported_backends)
510 510 default_repo_private = v.StringBoolean(if_missing=False)
511 511 default_repo_enable_statistics = v.StringBoolean(if_missing=False)
512 512 default_repo_enable_downloads = v.StringBoolean(if_missing=False)
513 513 default_repo_enable_locking = v.StringBoolean(if_missing=False)
514 514
515 515 return _DefaultsForm
516 516
517 517
518 518 def AuthSettingsForm():
519 519 class _AuthSettingsForm(formencode.Schema):
520 520 allow_extra_fields = True
521 521 filter_extra_fields = True
522 522 auth_plugins = All(v.ValidAuthPlugins(),
523 523 v.UniqueListFromString()(not_empty=True))
524 524
525 525 return _AuthSettingsForm
526 526
527 527
528 528 def UserExtraEmailForm():
529 529 class _UserExtraEmailForm(formencode.Schema):
530 530 email = All(v.UniqSystemEmail(), v.Email(not_empty=True))
531 531 return _UserExtraEmailForm
532 532
533 533
534 534 def UserExtraIpForm():
535 535 class _UserExtraIpForm(formencode.Schema):
536 536 ip = v.ValidIp()(not_empty=True)
537 537 return _UserExtraIpForm
538 538
539 539
540 540
541 541 def PullRequestForm(repo_id):
542 542 class ReviewerForm(formencode.Schema):
543 543 user_id = v.Int(not_empty=True)
544 544 reasons = All()
545 545 mandatory = v.StringBoolean()
546 546
547 547 class _PullRequestForm(formencode.Schema):
548 548 allow_extra_fields = True
549 549 filter_extra_fields = True
550 550
551 551 common_ancestor = v.UnicodeString(strip=True, required=True)
552 552 source_repo = v.UnicodeString(strip=True, required=True)
553 553 source_ref = v.UnicodeString(strip=True, required=True)
554 554 target_repo = v.UnicodeString(strip=True, required=True)
555 555 target_ref = v.UnicodeString(strip=True, required=True)
556 556 revisions = All(#v.NotReviewedRevisions(repo_id)(),
557 557 v.UniqueList()(not_empty=True))
558 558 review_members = formencode.ForEach(ReviewerForm())
559 559 pullrequest_title = v.UnicodeString(strip=True, required=True)
560 560 pullrequest_desc = v.UnicodeString(strip=True, required=False)
561 561
562 562 return _PullRequestForm
563 563
564 564
565 565 def IssueTrackerPatternsForm():
566 566 class _IssueTrackerPatternsForm(formencode.Schema):
567 567 allow_extra_fields = True
568 568 filter_extra_fields = False
569 569 chained_validators = [v.ValidPattern()]
570 570 return _IssueTrackerPatternsForm
General Comments 0
You need to be logged in to leave comments. Login now