##// END OF EJS Templates
pull-request: code cleanup...
marcink -
r1979:f2f8f5ce default
parent child Browse files
Show More
@@ -35,13 +35,13 b' def admin_routes(config):'
35 35
36 36 config.add_route(
37 37 name='pull_requests_global_0', # backward compat
38 pattern='/pull_requests/{pull_request_id:[0-9]+}')
38 pattern='/pull_requests/{pull_request_id:\d+}')
39 39 config.add_route(
40 40 name='pull_requests_global_1', # backward compat
41 pattern='/pull-requests/{pull_request_id:[0-9]+}')
41 pattern='/pull-requests/{pull_request_id:\d+}')
42 42 config.add_route(
43 43 name='pull_requests_global',
44 pattern='/pull-request/{pull_request_id:[0-9]+}')
44 pattern='/pull-request/{pull_request_id:\d+}')
45 45
46 46 config.add_route(
47 47 name='admin_settings_open_source',
@@ -54,8 +54,10 b' class AdminMainView(BaseAppView):'
54 54 :param pull_request_id: id of pull requests in the system
55 55 """
56 56
57 pull_request_id = self.request.matchdict.get('pull_request_id')
58 pull_request = PullRequest.get_or_404(pull_request_id)
57 pull_request = PullRequest.get_or_404(
58 self.request.matchdict['pull_request_id'])
59 pull_request_id = pull_request.pull_request_id
60
59 61 repo_name = pull_request.target_repo.repo_name
60 62
61 63 raise HTTPFound(
@@ -113,7 +113,7 b' class TestAdminRepoSettingsAdvanced(obje'
113 113 # mark it as None
114 114 response = self.app.post(
115 115 route_path('edit_repo_advanced_fork', repo_name=backend.repo_name),
116 params={'id_fork_of': None, '_method': 'put',
116 params={'id_fork_of': None,
117 117 'csrf_token': csrf_token})
118 118 assert_session_flash(
119 119 response,
@@ -265,7 +265,7 b' class RepoPullRequestsView(RepoAppView, '
265 265 route_name='pullrequest_show', request_method='GET',
266 266 renderer='rhodecode:templates/pullrequests/pullrequest_show.mako')
267 267 def pull_request_show(self):
268 pull_request_id = self.request.matchdict.get('pull_request_id')
268 pull_request_id = self.request.matchdict['pull_request_id']
269 269
270 270 c = self.load_default_context()
271 271
@@ -832,8 +832,8 b' class RepoPullRequestsView(RepoAppView, '
832 832 route_name='pullrequest_update', request_method='POST',
833 833 renderer='json_ext')
834 834 def pull_request_update(self):
835 pull_request_id = self.request.matchdict['pull_request_id']
836 pull_request = PullRequest.get_or_404(pull_request_id)
835 pull_request = PullRequest.get_or_404(
836 self.request.matchdict['pull_request_id'])
837 837
838 838 # only owner or admin can update it
839 839 allowed_to_update = PullRequestModel().check_user_update(
@@ -843,7 +843,7 b' class RepoPullRequestsView(RepoAppView, '
843 843
844 844 if 'review_members' in controls:
845 845 self._update_reviewers(
846 pull_request_id, controls['review_members'],
846 pull_request, controls['review_members'],
847 847 pull_request.reviewer_data)
848 848 elif str2bool(self.request.POST.get('update_commits', 'false')):
849 849 self._update_commits(pull_request)
@@ -930,8 +930,8 b' class RepoPullRequestsView(RepoAppView, '
930 930 After successful merging, the pull request is automatically
931 931 closed, with a relevant comment.
932 932 """
933 pull_request_id = self.request.matchdict['pull_request_id']
934 pull_request = PullRequest.get_or_404(pull_request_id)
933 pull_request = PullRequest.get_or_404(
934 self.request.matchdict['pull_request_id'])
935 935
936 936 check = MergeCheck.validate(pull_request, self._rhodecode_db_user)
937 937 merge_possible = not check.failed
@@ -974,7 +974,7 b' class RepoPullRequestsView(RepoAppView, '
974 974 merge_resp.failure_reason)
975 975 h.flash(msg, category='error')
976 976
977 def _update_reviewers(self, pull_request_id, review_members, reviewer_rules):
977 def _update_reviewers(self, pull_request, review_members, reviewer_rules):
978 978 _ = self.request.translate
979 979 get_default_reviewers_data, validate_default_reviewers = \
980 980 PullRequestModel().get_reviewer_functions()
@@ -987,7 +987,7 b' class RepoPullRequestsView(RepoAppView, '
987 987 return
988 988
989 989 PullRequestModel().update_reviewers(
990 pull_request_id, reviewers, self._rhodecode_user)
990 pull_request, reviewers, self._rhodecode_user)
991 991 h.flash(_('Pull request reviewers updated.'), category='success')
992 992 Session().commit()
993 993
@@ -1002,8 +1002,8 b' class RepoPullRequestsView(RepoAppView, '
1002 1002 def pull_request_delete(self):
1003 1003 _ = self.request.translate
1004 1004
1005 pull_request_id = self.request.matchdict['pull_request_id']
1006 pull_request = PullRequest.get_or_404(pull_request_id)
1005 pull_request = PullRequest.get_or_404(
1006 self.request.matchdict['pull_request_id'])
1007 1007
1008 1008 pr_closed = pull_request.is_closed()
1009 1009 allowed_to_delete = PullRequestModel().check_user_delete(
@@ -1031,8 +1031,11 b' class RepoPullRequestsView(RepoAppView, '
1031 1031 renderer='json_ext')
1032 1032 def pull_request_comment_create(self):
1033 1033 _ = self.request.translate
1034 pull_request_id = self.request.matchdict['pull_request_id']
1035 pull_request = PullRequest.get_or_404(pull_request_id)
1034
1035 pull_request = PullRequest.get_or_404(
1036 self.request.matchdict['pull_request_id'])
1037 pull_request_id = pull_request.pull_request_id
1038
1036 1039 if pull_request.is_closed():
1037 1040 log.debug('comment: forbidden because pull request is closed')
1038 1041 raise HTTPForbidden()
@@ -1080,7 +1083,7 b' class RepoPullRequestsView(RepoAppView, '
1080 1083 text=text,
1081 1084 repo=self.db_repo.repo_id,
1082 1085 user=self._rhodecode_user.user_id,
1083 pull_request=pull_request_id,
1086 pull_request=pull_request,
1084 1087 f_path=self.request.POST.get('f_path'),
1085 1088 line_no=self.request.POST.get('line'),
1086 1089 status_change=(ChangesetStatus.get_status_lbl(status)
@@ -1102,7 +1105,7 b' class RepoPullRequestsView(RepoAppView, '
1102 1105 status,
1103 1106 self._rhodecode_user.user_id,
1104 1107 comment,
1105 pull_request=pull_request_id
1108 pull_request=pull_request
1106 1109 )
1107 1110
1108 1111 Session().flush()
@@ -1142,15 +1145,17 b' class RepoPullRequestsView(RepoAppView, '
1142 1145 route_name='pullrequest_comment_delete', request_method='POST',
1143 1146 renderer='json_ext')
1144 1147 def pull_request_comment_delete(self):
1145 pull_request_id = self.request.matchdict['pull_request_id']
1146 comment_id = self.request.matchdict['comment_id']
1148 pull_request = PullRequest.get_or_404(
1149 self.request.matchdict['pull_request_id'])
1147 1150
1148 pull_request = PullRequest.get_or_404(pull_request_id)
1151 comment = ChangesetComment.get_or_404(
1152 self.request.matchdict['comment_id'])
1153 comment_id = comment.comment_id
1154
1149 1155 if pull_request.is_closed():
1150 1156 log.debug('comment: forbidden because pull request is closed')
1151 1157 raise HTTPForbidden()
1152 1158
1153 comment = ChangesetComment.get_or_404(comment_id)
1154 1159 if not comment:
1155 1160 log.debug('Comment with id:%s not found, skipping', comment_id)
1156 1161 # comment already deleted in another call probably
@@ -544,7 +544,6 b' var CommentsController = function() {'
544 544 var comment_id = $comment.attr('data-comment-id');
545 545 var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__', comment_id);
546 546 var postData = {
547 '_method': 'delete',
548 547 'csrf_token': CSRF_TOKEN
549 548 };
550 549
@@ -372,7 +372,6 b' var _updatePullRequest = function(repo_n'
372 372 */
373 373 var updateCommits = function(repo_name, pull_request_id) {
374 374 var postData = {
375 '_method': 'put',
376 375 'update_commits': true};
377 376 _updatePullRequest(repo_name, pull_request_id, postData);
378 377 };
General Comments 0
You need to be logged in to leave comments. Login now