Show More
@@ -96,6 +96,12 b' class PullrequestsController(BaseRepoCon' | |||
|
96 | 96 | #if repo doesn't have default branch return first found |
|
97 | 97 | return repo.branches.keys()[0] |
|
98 | 98 | |
|
99 | def _get_is_allowed_change_status(self, pull_request): | |
|
100 | owner = self.rhodecode_user.user_id == pull_request.user_id | |
|
101 | reviewer = self.rhodecode_user.user_id in [x.user_id for x in | |
|
102 | pull_request.reviewers] | |
|
103 | return (self.rhodecode_user.admin or owner or reviewer) | |
|
104 | ||
|
99 | 105 | def show_all(self, repo_name): |
|
100 | 106 | c.pull_requests = PullRequestModel().get_all(repo_name) |
|
101 | 107 | c.repo_name = repo_name |
@@ -334,7 +340,7 b' class PullrequestsController(BaseRepoCon' | |||
|
334 | 340 | c.users_groups_array = repo_model.get_users_groups_js() |
|
335 | 341 | c.pull_request = PullRequest.get_or_404(pull_request_id) |
|
336 | 342 | c.target_repo = c.pull_request.org_repo.repo_name |
|
337 | ||
|
343 | c.allowed_to_change_status = self._get_is_allowed_change_status(c.pull_request) | |
|
338 | 344 | cc_model = ChangesetCommentsModel() |
|
339 | 345 | cs_model = ChangesetStatusModel() |
|
340 | 346 | _cs_statuses = cs_model.get_statuses(c.pull_request.org_repo, |
@@ -405,7 +411,9 b' class PullrequestsController(BaseRepoCon' | |||
|
405 | 411 | status = request.POST.get('changeset_status') |
|
406 | 412 | change_status = request.POST.get('change_changeset_status') |
|
407 | 413 | text = request.POST.get('text') |
|
408 | if status and change_status: | |
|
414 | ||
|
415 | allowed_to_change_status = self._get_is_allowed_change_status(pull_request) | |
|
416 | if status and change_status and allowed_to_change_status: | |
|
409 | 417 | text = text or (_('Status change -> %s') |
|
410 | 418 | % ChangesetStatus.get_status_lbl(status)) |
|
411 | 419 | comm = ChangesetCommentsModel().create( |
@@ -416,32 +424,34 b' class PullrequestsController(BaseRepoCon' | |||
|
416 | 424 | f_path=request.POST.get('f_path'), |
|
417 | 425 | line_no=request.POST.get('line'), |
|
418 | 426 | status_change=(ChangesetStatus.get_status_lbl(status) |
|
419 |
|
|
|
427 | if status and change_status and allowed_to_change_status else None) | |
|
420 | 428 | ) |
|
421 | 429 | |
|
422 | # get status if set ! | |
|
423 | if status and change_status: | |
|
424 | ChangesetStatusModel().set_status( | |
|
425 | c.rhodecode_db_repo.repo_id, | |
|
426 | status, | |
|
427 | c.rhodecode_user.user_id, | |
|
428 | comm, | |
|
429 | pull_request=pull_request_id | |
|
430 | ) | |
|
431 | 430 | action_logger(self.rhodecode_user, |
|
432 | 431 | 'user_commented_pull_request:%s' % pull_request_id, |
|
433 | 432 | c.rhodecode_db_repo, self.ip_addr, self.sa) |
|
434 | 433 | |
|
435 | if request.POST.get('save_close'): | |
|
436 |
|
|
|
437 | PullRequestModel().close_pull_request(pull_request_id) | |
|
438 | action_logger(self.rhodecode_user, | |
|
439 | 'user_closed_pull_request:%s' % pull_request_id, | |
|
440 | c.rhodecode_db_repo, self.ip_addr, self.sa) | |
|
441 | else: | |
|
442 | h.flash(_('Closing pull request on other statuses than ' | |
|
443 | 'rejected or approved forbidden'), | |
|
444 | category='warning') | |
|
434 | if allowed_to_change_status: | |
|
435 | # get status if set ! | |
|
436 | if status and change_status: | |
|
437 | ChangesetStatusModel().set_status( | |
|
438 | c.rhodecode_db_repo.repo_id, | |
|
439 | status, | |
|
440 | c.rhodecode_user.user_id, | |
|
441 | comm, | |
|
442 | pull_request=pull_request_id | |
|
443 | ) | |
|
444 | ||
|
445 | if request.POST.get('save_close'): | |
|
446 | if status in ['rejected', 'approved']: | |
|
447 | PullRequestModel().close_pull_request(pull_request_id) | |
|
448 | action_logger(self.rhodecode_user, | |
|
449 | 'user_closed_pull_request:%s' % pull_request_id, | |
|
450 | c.rhodecode_db_repo, self.ip_addr, self.sa) | |
|
451 | else: | |
|
452 | h.flash(_('Closing pull request on other statuses than ' | |
|
453 | 'rejected or approved forbidden'), | |
|
454 | category='warning') | |
|
445 | 455 | |
|
446 | 456 | Session().commit() |
|
447 | 457 |
@@ -109,7 +109,7 b'' | |||
|
109 | 109 | </%def> |
|
110 | 110 | |
|
111 | 111 | ## MAIN COMMENT FORM |
|
112 | <%def name="comments(post_url, cur_status, close_btn=False)"> | |
|
112 | <%def name="comments(post_url, cur_status, close_btn=False, change_status=True)"> | |
|
113 | 113 | |
|
114 | 114 | <div class="comments"> |
|
115 | 115 | %if c.rhodecode_user.username != 'default': |
@@ -121,9 +121,12 b'' | |||
|
121 | 121 | ${(_('Comments parsed using %s syntax with %s support.') % (('<a href="%s">RST</a>' % h.url('rst_help')), |
|
122 | 122 | '<span style="color:#003367" class="tooltip" title="%s">@mention</span>' % |
|
123 | 123 | _('Use @username inside this text to send notification to this RhodeCode user')))|n} |
|
124 | %if change_status: | |
|
124 | 125 | | <label for="show_changeset_status_box" class="tooltip" title="${_('Check this to change current status of code-review for this changeset')}"> ${_('change status')}</label> |
|
125 | 126 | <input style="vertical-align: bottom;margin-bottom:-2px" id="show_changeset_status_box" type="checkbox" name="change_changeset_status" /> |
|
127 | %endif | |
|
126 | 128 | </div> |
|
129 | %if change_status: | |
|
127 | 130 | <div id="status_block_container" class="status-block" style="display:none"> |
|
128 | 131 | %for status,lbl in c.changeset_statuses: |
|
129 | 132 | <div class=""> |
@@ -132,13 +135,14 b'' | |||
|
132 | 135 | </div> |
|
133 | 136 | %endfor |
|
134 | 137 | </div> |
|
138 | %endif | |
|
135 | 139 | <div class="mentions-container" id="mentions_container"></div> |
|
136 | 140 | ${h.textarea('text')} |
|
137 | 141 | </div> |
|
138 | 142 | <div class="comment-button"> |
|
139 | 143 | ${h.submit('save', _('Comment'), class_="ui-btn large")} |
|
140 | %if close_btn: | |
|
141 | ${h.submit('save_close', _('Comment and close'), class_='ui-btn blue large %s' % 'hidden' if cur_status in ['not_reviewd','under_review'] else '')} | |
|
144 | %if close_btn and change_status: | |
|
145 | ${h.submit('save_close', _('Comment and close'), class_='ui-btn blue large %s' % ('hidden' if cur_status in ['not_reviewed','under_review'] else ''))} | |
|
142 | 146 | %endif |
|
143 | 147 | </div> |
|
144 | 148 | ${h.end_form()} |
@@ -166,7 +166,7 b'' | |||
|
166 | 166 | ${comment.comments(h.url('pullrequest_comment', repo_name=c.repo_name, |
|
167 | 167 | pull_request_id=c.pull_request.pull_request_id), |
|
168 | 168 | c.current_changeset_status, |
|
169 | close_btn=True)} | |
|
169 | close_btn=True, change_status=c.allowed_to_change_status)} | |
|
170 | 170 | %endif |
|
171 | 171 | |
|
172 | 172 | <script type="text/javascript"> |
General Comments 0
You need to be logged in to leave comments.
Login now