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