comparison rhodecode/model/forms.py @ 2460:12fa0c19c42f beta

validating choices for landing_rev
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 15 Jun 2012 00:05:20 +0200
parents 9492ab68331f
children 4419551b2915
comparison
equal deleted inserted replaced
2459:9492ab68331f 2460:12fa0c19c42f
651 email = All(ValidSystemEmail(), Email(not_empty=True)) 651 email = All(ValidSystemEmail(), Email(not_empty=True))
652 return _PasswordResetForm 652 return _PasswordResetForm
653 653
654 654
655 def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(), 655 def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
656 repo_groups=[]): 656 repo_groups=[], landing_revs=[]):
657 class _RepoForm(formencode.Schema): 657 class _RepoForm(formencode.Schema):
658 allow_extra_fields = True 658 allow_extra_fields = True
659 filter_extra_fields = False 659 filter_extra_fields = False
660 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), 660 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True),
661 SlugifyName()) 661 SlugifyName())
664 repo_type = OneOf(supported_backends) 664 repo_type = OneOf(supported_backends)
665 description = UnicodeString(strip=True, min=1, not_empty=False) 665 description = UnicodeString(strip=True, min=1, not_empty=False)
666 private = StringBoolean(if_missing=False) 666 private = StringBoolean(if_missing=False)
667 enable_statistics = StringBoolean(if_missing=False) 667 enable_statistics = StringBoolean(if_missing=False)
668 enable_downloads = StringBoolean(if_missing=False) 668 enable_downloads = StringBoolean(if_missing=False)
669 landing_rev = UnicodeString(strip=True, min=1, not_empty=True) 669 landing_rev = OneOf(landing_revs, hideList=True)
670 670
671 if edit: 671 if edit:
672 #this is repo owner 672 #this is repo owner
673 user = All(UnicodeString(not_empty=True), ValidRepoUser) 673 user = All(UnicodeString(not_empty=True), ValidRepoUser)
674 674
676 ValidRepoName(edit, old_data), 676 ValidRepoName(edit, old_data),
677 ValidPerms()] 677 ValidPerms()]
678 return _RepoForm 678 return _RepoForm
679 679
680 680
681 def RepoForkForm(edit=False, old_data={}, 681 def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
682 supported_backends=BACKENDS.keys(), repo_groups=[]): 682 repo_groups=[]):
683 class _RepoForkForm(formencode.Schema): 683 class _RepoForkForm(formencode.Schema):
684 allow_extra_fields = True 684 allow_extra_fields = True
685 filter_extra_fields = False 685 filter_extra_fields = False
686 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), 686 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True),
687 SlugifyName()) 687 SlugifyName())
695 chained_validators = [ValidForkName(edit, old_data)] 695 chained_validators = [ValidForkName(edit, old_data)]
696 696
697 return _RepoForkForm 697 return _RepoForkForm
698 698
699 699
700 def RepoSettingsForm(edit=False, old_data={}, 700 def RepoSettingsForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
701 supported_backends=BACKENDS.keys(), repo_groups=[]): 701 repo_groups=[], landing_revs=[]):
702 class _RepoForm(formencode.Schema): 702 class _RepoForm(formencode.Schema):
703 allow_extra_fields = True 703 allow_extra_fields = True
704 filter_extra_fields = False 704 filter_extra_fields = False
705 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), 705 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True),
706 SlugifyName()) 706 SlugifyName())
707 description = UnicodeString(strip=True, min=1, not_empty=True) 707 description = UnicodeString(strip=True, min=1, not_empty=True)
708 repo_group = OneOf(repo_groups, hideList=True) 708 repo_group = OneOf(repo_groups, hideList=True)
709 private = StringBoolean(if_missing=False) 709 private = StringBoolean(if_missing=False)
710 landing_rev = UnicodeString(strip=True, min=1, not_empty=True) 710 landing_rev = OneOf(landing_revs, hideList=True)
711 chained_validators = [ValidRepoName(edit, old_data), ValidPerms(), 711 chained_validators = [ValidRepoName(edit, old_data), ValidPerms(),
712 ValidSettings] 712 ValidSettings]
713 return _RepoForm 713 return _RepoForm
714 714
715 715