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