##// END OF EJS Templates
validating choices for landing_rev
marcink -
r2472:e70ebd6d beta
parent child Browse files
Show More
@@ -70,7 +70,8 class ReposController(BaseController):
70 70 repo_model = RepoModel()
71 71 c.users_array = repo_model.get_users_js()
72 72 c.users_groups_array = repo_model.get_users_groups_js()
73 c.landing_revs = ScmModel().get_repo_landing_revs()
73 choices, c.landing_revs = ScmModel().get_repo_landing_revs()
74 c.landing_revs_choices = choices
74 75
75 76 def __load_data(self, repo_name=None):
76 77 """
@@ -92,7 +93,9 class ReposController(BaseController):
92 93
93 94 return redirect(url('repos'))
94 95
95 c.landing_revs = ScmModel().get_repo_landing_revs(c.repo_info)
96 choices, c.landing_revs = ScmModel().get_repo_landing_revs(c.repo_info)
97 c.landing_revs_choices = choices
98
96 99 c.default_user_id = User.get_by_username('default').user_id
97 100 c.in_public_journal = UserFollowing.query()\
98 101 .filter(UserFollowing.user_id == c.default_user_id)\
@@ -140,7 +143,8 class ReposController(BaseController):
140 143 self.__load_defaults()
141 144 form_result = {}
142 145 try:
143 form_result = RepoForm(repo_groups=c.repo_groups_choices)()\
146 form_result = RepoForm(repo_groups=c.repo_groups_choices,
147 landing_revs=c.landing_revs_choices)()\
144 148 .to_python(dict(request.POST))
145 149 RepoModel().create(form_result, self.rhodecode_user)
146 150 if form_result['clone_uri']:
@@ -208,7 +212,8 class ReposController(BaseController):
208 212 repo_model = RepoModel()
209 213 changed_name = repo_name
210 214 _form = RepoForm(edit=True, old_data={'repo_name': repo_name},
211 repo_groups=c.repo_groups_choices)()
215 repo_groups=c.repo_groups_choices,
216 landing_revs=c.landing_revs_choices)()
212 217 try:
213 218 form_result = _form.to_python(dict(request.POST))
214 219 repo = repo_model.update(repo_name, form_result)
@@ -43,6 +43,7 from rhodecode.model.forms import RepoSe
43 43 from rhodecode.model.repo import RepoModel
44 44 from rhodecode.model.db import RepoGroup
45 45 from rhodecode.model.meta import Session
46 from rhodecode.model.scm import ScmModel
46 47
47 48 log = logging.getLogger(__name__)
48 49
@@ -60,6 +61,8 class SettingsController(BaseRepoControl
60 61 repo_model = RepoModel()
61 62 c.users_array = repo_model.get_users_js()
62 63 c.users_groups_array = repo_model.get_users_groups_js()
64 choices, c.landing_revs = ScmModel().get_repo_landing_revs()
65 c.landing_revs_choices = choices
63 66
64 67 @HasRepoPermissionAllDecorator('repository.admin')
65 68 def index(self, repo_name):
@@ -94,7 +97,8 class SettingsController(BaseRepoControl
94 97
95 98 _form = RepoSettingsForm(edit=True,
96 99 old_data={'repo_name': repo_name},
97 repo_groups=c.repo_groups_choices)()
100 repo_groups=c.repo_groups_choices,
101 landing_revs=c.landing_revs_choices)()
98 102 try:
99 103 form_result = _form.to_python(dict(request.POST))
100 104
@@ -653,7 +653,7 def PasswordResetForm():
653 653
654 654
655 655 def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
656 repo_groups=[]):
656 repo_groups=[], landing_revs=[]):
657 657 class _RepoForm(formencode.Schema):
658 658 allow_extra_fields = True
659 659 filter_extra_fields = False
@@ -666,7 +666,7 def RepoForm(edit=False, old_data={}, su
666 666 private = StringBoolean(if_missing=False)
667 667 enable_statistics = StringBoolean(if_missing=False)
668 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 671 if edit:
672 672 #this is repo owner
@@ -678,8 +678,8 def RepoForm(edit=False, old_data={}, su
678 678 return _RepoForm
679 679
680 680
681 def RepoForkForm(edit=False, old_data={},
682 supported_backends=BACKENDS.keys(), repo_groups=[]):
681 def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
682 repo_groups=[]):
683 683 class _RepoForkForm(formencode.Schema):
684 684 allow_extra_fields = True
685 685 filter_extra_fields = False
@@ -697,8 +697,8 def RepoForkForm(edit=False, old_data={}
697 697 return _RepoForkForm
698 698
699 699
700 def RepoSettingsForm(edit=False, old_data={},
701 supported_backends=BACKENDS.keys(), repo_groups=[]):
700 def RepoSettingsForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
701 repo_groups=[], landing_revs=[]):
702 702 class _RepoForm(formencode.Schema):
703 703 allow_extra_fields = True
704 704 filter_extra_fields = False
@@ -707,7 +707,7 def RepoSettingsForm(edit=False, old_dat
707 707 description = UnicodeString(strip=True, min=1, not_empty=True)
708 708 repo_group = OneOf(repo_groups, hideList=True)
709 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 711 chained_validators = [ValidRepoName(edit, old_data), ValidPerms(),
712 712 ValidSettings]
713 713 return _RepoForm
@@ -482,24 +482,31 class ScmModel(BaseModel):
482 482 :param repo:
483 483 :type repo:
484 484 """
485
485 486 hist_l = []
487 choices = []
486 488 repo = self.__get_repo(repo)
487 489 hist_l.append(['tip', _('latest tip')])
490 choices.append('tip')
488 491 if not repo:
489 return hist_l
492 return choices, hist_l
490 493
491 494 repo = repo.scm_instance
495
492 496 branches_group = ([(k, k) for k, v in
493 497 repo.branches.iteritems()], _("Branches"))
494 498 hist_l.append(branches_group)
499 choices.extend([x[0] for x in branches_group[0]])
495 500
496 501 if repo.alias == 'hg':
497 502 bookmarks_group = ([(k, k) for k, v in
498 503 repo.bookmarks.iteritems()], _("Bookmarks"))
499 504 hist_l.append(bookmarks_group)
505 choices.extend([x[0] for x in bookmarks_group[0]])
500 506
501 507 tags_group = ([(k, k) for k, v in
502 508 repo.tags.iteritems()], _("Tags"))
503 509 hist_l.append(tags_group)
510 choices.extend([x[0] for x in tags_group[0]])
504 511
505 return hist_l
512 return choices, hist_l
General Comments 0
You need to be logged in to leave comments. Login now