##// END OF EJS Templates
Authors of pull-requests can now delete them
marcink -
r2746:49a4864b beta
parent child Browse files
Show More
@@ -462,6 +462,11 b' def make_map(config):'
462 controller='pullrequests',
462 controller='pullrequests',
463 action='update', conditions=dict(function=check_repo,
463 action='update', conditions=dict(function=check_repo,
464 method=["PUT"]))
464 method=["PUT"]))
465 rmap.connect('pullrequest_delete',
466 '/{repo_name:.*?}/pull-request/{pull_request_id}',
467 controller='pullrequests',
468 action='delete', conditions=dict(function=check_repo,
469 method=["DELETE"]))
465
470
466 rmap.connect('pullrequest_show_all',
471 rmap.connect('pullrequest_show_all',
467 '/{repo_name:.*?}/pull-request',
472 '/{repo_name:.*?}/pull-request',
@@ -203,6 +203,20 b' class PullrequestsController(BaseRepoCon'
203 Session.commit()
203 Session.commit()
204 return True
204 return True
205
205
206 @NotAnonymous()
207 @jsonify
208 def delete(self, repo_name, pull_request_id):
209 pull_request = PullRequest.get_or_404(pull_request_id)
210 #only owner can delete it !
211 if pull_request.author.user_id == c.rhodecode_user.user_id:
212 PullRequestModel().delete(pull_request)
213 Session().commit()
214 h.flash(_('Successfully deleted pull request'),
215 category='success')
216 return redirect(url('admin_settings_my_account'))
217 else:
218 raise HTTPForbidden()
219
206 def _load_compare_data(self, pull_request, enable_comments=True):
220 def _load_compare_data(self, pull_request, enable_comments=True):
207 """
221 """
208 Load context data needed for generating compare diff
222 Load context data needed for generating compare diff
@@ -125,6 +125,10 b' class PullRequestModel(BaseModel):'
125 if reviewer:
125 if reviewer:
126 self.sa.delete(reviewer)
126 self.sa.delete(reviewer)
127
127
128 def delete(self, pull_request):
129 pull_request = self.__get_pull_request(pull_request)
130 Session().delete(pull_request)
131
128 def close_pull_request(self, pull_request):
132 def close_pull_request(self, pull_request):
129 pull_request = self.__get_pull_request(pull_request)
133 pull_request = self.__get_pull_request(pull_request)
130 pull_request.status = PullRequest.STATUS_CLOSED
134 pull_request.status = PullRequest.STATUS_CLOSED
@@ -4,9 +4,16 b''
4 %if c.my_pull_requests:
4 %if c.my_pull_requests:
5 %for pull_request in c.my_pull_requests:
5 %for pull_request in c.my_pull_requests:
6 <li>
6 <li>
7 <div style="float:left">
7 <a href="${h.url('pullrequest_show',repo_name=pull_request.other_repo.repo_name,pull_request_id=pull_request.pull_request_id)}">
8 <a href="${h.url('pullrequest_show',repo_name=pull_request.other_repo.repo_name,pull_request_id=pull_request.pull_request_id)}">
8 ${_('Pull request #%s opened on %s') % (pull_request.pull_request_id, h.fmt_date(pull_request.created_on))}
9 ${_('Pull request #%s opened on %s') % (pull_request.pull_request_id, h.fmt_date(pull_request.created_on))}
9 </a>
10 </a>
11 </div>
12 <div style="float:left;margin-top: -5px">
13 ${h.form(url('pullrequest_delete', repo_name=pull_request.other_repo.repo_name, pull_request_id=pull_request.pull_request_id),method='delete')}
14 ${h.submit('remove_%s' % pull_request.pull_request_id,'',class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this pull request')+"');")}
15 ${h.end_form()}
16 </div>
10 </li>
17 </li>
11 %endfor
18 %endfor
12 %else:
19 %else:
@@ -14,7 +21,7 b''
14 %endif
21 %endif
15 </ul>
22 </ul>
16
23
17 <div class="pullrequests_section_head">${_('I participate in')}</div>
24 <div class="pullrequests_section_head" style="clear:both">${_('I participate in')}</div>
18 <ul>
25 <ul>
19 %if c.my_pull_requests:
26 %if c.my_pull_requests:
20 %for pull_request in c.participate_in_pull_requests:
27 %for pull_request in c.participate_in_pull_requests:
General Comments 0
You need to be logged in to leave comments. Login now