##// END OF EJS Templates
pull requests: make it possible control display of closed PRs and whether it is PRs to or from repo
Mads Kiilerich -
r4024:73ef2a5d default
parent child Browse files
Show More
@@ -226,7 +226,9 b' class PullrequestsController(BaseRepoCon'
226 226 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
227 227 'repository.admin')
228 228 def show_all(self, repo_name):
229 c.pull_requests = PullRequestModel().get_all(repo_name)
229 c.from_ = request.GET.get('from_') or ''
230 c.closed = request.GET.get('closed') or ''
231 c.pull_requests = PullRequestModel().get_all(repo_name, from_=c.from_, closed=c.closed)
230 232 c.repo_name = repo_name
231 233 p = safe_int(request.GET.get('page', 1), 1)
232 234
@@ -47,12 +47,19 b' class PullRequestModel(BaseModel):'
47 47 def __get_pull_request(self, pull_request):
48 48 return self._get_instance(PullRequest, pull_request)
49 49
50 def get_all(self, repo):
51 repo = self._get_repo(repo)
52 return PullRequest.query()\
53 .filter(PullRequest.other_repo == repo)\
54 .order_by(PullRequest.created_on.desc())\
55 .all()
50 def get_all(self, repo_name, from_=False, closed=False):
51 """Get all PRs for repo.
52 Default is all PRs to the repo, PRs from the repo if from_.
53 Closed PRs are only included if closed is true."""
54 repo = self._get_repo(repo_name)
55 q = PullRequest.query()
56 if from_:
57 q = q.filter(PullRequest.org_repo == repo)
58 else:
59 q = q.filter(PullRequest.other_repo == repo)
60 if not closed:
61 q = q.filter(PullRequest.status != PullRequest.STATUS_CLOSED)
62 return q.order_by(PullRequest.created_on.desc()).all()
56 63
57 64 def create(self, created_by, org_repo, org_ref, other_repo, other_ref,
58 65 revisions, reviewers, title, description=None):
@@ -160,7 +160,7 b''
160 160 </ul>
161 161 </li>
162 162 <li ${is_current('showpullrequest')}>
163 <a href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}" title="${_('Show Pull Requests')}" class="pull-request">${_('Pull Requests')}
163 <a href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}" title="${_('Show Pull Requests for %s') % c.repo_name}" class="pull-request">${_('Pull Requests')}
164 164 %if c.repository_pull_requests:
165 165 <span>${c.repository_pull_requests}</span>
166 166 %endif
@@ -4,7 +4,7 b''
4 4 <div class="pr ${'pr-closed' if pr.is_closed() else ''}">
5 5 <div class="pr-title">
6 6 <img src="${h.url('/images/icons/flag_status_%s.png' % str(pr.last_review_status))}" />
7 <a href="${h.url('pullrequest_show',repo_name=c.repo_name,pull_request_id=pr.pull_request_id)}">
7 <a href="${h.url('pullrequest_show',repo_name=pr.other_repo.repo_name,pull_request_id=pr.pull_request_id)}">
8 8 ${_('Pull request #%s opened by %s on %s') % (pr.pull_request_id, pr.author.full_name, h.fmt_date(pr.created_on))}
9 9 </a>
10 10 %if pr.is_closed():
@@ -5,7 +5,11 b''
5 5 </%def>
6 6
7 7 <%def name="breadcrumbs_links()">
8 ${_('Pull requests')}
8 %if c.from_:
9 ${_('Pull requests from %s') % c.repo_name}
10 %else:
11 ${_('Pull requests to %s') % c.repo_name}
12 %endif
9 13 </%def>
10 14
11 15 <%def name="page_nav()">
@@ -20,7 +24,27 b''
20 24 <div class="title">
21 25 ${self.breadcrumbs()}
22 26 </div>
27
28 <div style="margin: 0 20px">
29 <div>
30 %if c.from_:
31 ${h.link_to(_('Instead, show pull requests to %s') % c.repo_name, h.url('pullrequest_show_all',repo_name=c.repo_name,closed=c.closed))}
32 %else:
33 ${h.link_to(_('Instead, show pull requests from %s') % c.repo_name, h.url('pullrequest_show_all',repo_name=c.repo_name,closed=c.closed,from_=1))}
34 %endif
35 </div>
36
37 <div>
38 %if c.closed:
39 ${h.link_to(_('Hide closed pull requests'), h.url('pullrequest_show_all',repo_name=c.repo_name,from_=c.from_))}
40 %else:
41 ${h.link_to(_('Show closed pull requests too'), h.url('pullrequest_show_all',repo_name=c.repo_name,from_=c.from_,closed=1))}
42 %endif
43 </div>
44 </div>
45
23 46 ${c.pullrequest_data}
47
24 48 </div>
25 49
26 50 </%def>
General Comments 0
You need to be logged in to leave comments. Login now