Commits

Marcin Kuzminski committed eb180eb

Fixed #585, checks for status of revision where to strict, and made opening pull request with those revision impossible due to previosly set status.
Checks now are made also for the repository.

  • Participants
  • Parent commits 5fba377

Comments (0)

Files changed (3)

File rhodecode/controllers/pullrequests.py

 
     @NotAnonymous()
     def create(self, repo_name):
+        repo = RepoModel()._get_repo(repo_name)
         try:
-            _form = PullRequestForm()().to_python(request.POST)
+            _form = PullRequestForm(repo.repo_id)().to_python(request.POST)
         except formencode.Invalid, errors:
             log.error(traceback.format_exc())
             if errors.error_dict.get('revisions'):

File rhodecode/model/forms.py

     return _UserExtraEmailForm
 
 
-def PullRequestForm():
+def PullRequestForm(repo_id):
     class _PullRequestForm(formencode.Schema):
         allow_extra_fields = True
         filter_extra_fields = True
         org_ref = v.UnicodeString(strip=True, required=True)
         other_repo = v.UnicodeString(strip=True, required=True)
         other_ref = v.UnicodeString(strip=True, required=True)
-        revisions = All(v.NotReviewedRevisions()(), v.UniqueList(not_empty=True))
+        revisions = All(v.NotReviewedRevisions(repo_id)(), v.UniqueList(not_empty=True))
         review_members = v.UniqueList(not_empty=True)
 
         pullrequest_title = v.UnicodeString(strip=True, required=True, min=3)

File rhodecode/model/validators.py

     return _validator
 
 
-def NotReviewedRevisions():
+def NotReviewedRevisions(repo_id):
     class _validator(formencode.validators.FancyValidator):
         messages = {
             'rev_already_reviewed':
             # check revisions if they are not reviewed, or a part of another
             # pull request
             statuses = ChangesetStatus.query()\
-                .filter(ChangesetStatus.revision.in_(value)).all()
+                .filter(ChangesetStatus.revision.in_(value))\
+                .filter(ChangesetStatus.repo_id == repo_id)\
+                .all()
+
             errors = []
             for cs in statuses:
                 if cs.pull_request_id: