##// END OF EJS Templates
pull-requests: forbid doing any changes on closed pull-requests....
marcink -
r2383:6726b773 default
parent child Browse files
Show More
@@ -199,18 +199,17 b' class TestPullrequestsView(object):'
199 def test_edit_title_description_closed(self, pr_util, csrf_token):
199 def test_edit_title_description_closed(self, pr_util, csrf_token):
200 pull_request = pr_util.create_pull_request()
200 pull_request = pr_util.create_pull_request()
201 pull_request_id = pull_request.pull_request_id
201 pull_request_id = pull_request.pull_request_id
202 repo_name = pull_request.target_repo.repo_name
202 pr_util.close()
203 pr_util.close()
203
204
204 response = self.app.post(
205 response = self.app.post(
205 route_path('pullrequest_update',
206 route_path('pullrequest_update',
206 repo_name=pull_request.target_repo.repo_name,
207 repo_name=repo_name, pull_request_id=pull_request_id),
207 pull_request_id=pull_request_id),
208 params={
208 params={
209 'edit_pull_request': 'true',
209 'edit_pull_request': 'true',
210 'title': 'New title',
210 'title': 'New title',
211 'description': 'New description',
211 'description': 'New description',
212 'csrf_token': csrf_token})
212 'csrf_token': csrf_token}, status=200)
213
214 assert_session_flash(
213 assert_session_flash(
215 response, u'Cannot update closed pull requests.',
214 response, u'Cannot update closed pull requests.',
216 category='error')
215 category='error')
@@ -887,8 +887,16 b' class RepoPullRequestsView(RepoAppView, '
887 def pull_request_update(self):
887 def pull_request_update(self):
888 pull_request = PullRequest.get_or_404(
888 pull_request = PullRequest.get_or_404(
889 self.request.matchdict['pull_request_id'])
889 self.request.matchdict['pull_request_id'])
890 _ = self.request.translate
890
891
891 self.load_default_context()
892 self.load_default_context()
893
894 if pull_request.is_closed():
895 log.debug('update: forbidden because pull request is closed')
896 msg = _(u'Cannot update closed pull requests.')
897 h.flash(msg, category='error')
898 return True
899
892 # only owner or admin can update it
900 # only owner or admin can update it
893 allowed_to_update = PullRequestModel().check_user_update(
901 allowed_to_update = PullRequestModel().check_user_update(
894 pull_request, self._rhodecode_user)
902 pull_request, self._rhodecode_user)
@@ -941,6 +941,9 b' class PullRequestModel(BaseModel):'
941 :param reviewer_data: list of tuples
941 :param reviewer_data: list of tuples
942 [(user, ['reason1', 'reason2'], mandatory_flag)]
942 [(user, ['reason1', 'reason2'], mandatory_flag)]
943 """
943 """
944 pull_request = self.__get_pull_request(pull_request)
945 if pull_request.is_closed():
946 raise ValueError('This pull request is closed')
944
947
945 reviewers = {}
948 reviewers = {}
946 for user_id, reasons, mandatory in reviewer_data:
949 for user_id, reasons, mandatory in reviewer_data:
@@ -950,7 +953,6 b' class PullRequestModel(BaseModel):'
950 'reasons': reasons, 'mandatory': mandatory}
953 'reasons': reasons, 'mandatory': mandatory}
951
954
952 reviewers_ids = set(reviewers.keys())
955 reviewers_ids = set(reviewers.keys())
953 pull_request = self.__get_pull_request(pull_request)
954 current_reviewers = PullRequestReviewers.query()\
956 current_reviewers = PullRequestReviewers.query()\
955 .filter(PullRequestReviewers.pull_request ==
957 .filter(PullRequestReviewers.pull_request ==
956 pull_request).all()
958 pull_request).all()
General Comments 0
You need to be logged in to leave comments. Login now