Mercurial > kallithea
changeset 4024:73ef2a5d3042
pull requests: make it possible control display of closed PRs and whether it is PRs to or from repo
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 05 Jun 2013 01:16:42 +0200 |
parents | e29b927d4de4 |
children | cd23cc2c9961 |
files | rhodecode/controllers/pullrequests.py rhodecode/model/pull_request.py rhodecode/templates/base/base.html rhodecode/templates/pullrequests/pullrequest_data.html rhodecode/templates/pullrequests/pullrequest_show_all.html |
diffstat | 5 files changed, 43 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/pullrequests.py Tue Jun 04 14:01:57 2013 +0200 +++ b/rhodecode/controllers/pullrequests.py Wed Jun 05 01:16:42 2013 +0200 @@ -226,7 +226,9 @@ @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin') def show_all(self, repo_name): - c.pull_requests = PullRequestModel().get_all(repo_name) + c.from_ = request.GET.get('from_') or '' + c.closed = request.GET.get('closed') or '' + c.pull_requests = PullRequestModel().get_all(repo_name, from_=c.from_, closed=c.closed) c.repo_name = repo_name p = safe_int(request.GET.get('page', 1), 1)
--- a/rhodecode/model/pull_request.py Tue Jun 04 14:01:57 2013 +0200 +++ b/rhodecode/model/pull_request.py Wed Jun 05 01:16:42 2013 +0200 @@ -47,12 +47,19 @@ def __get_pull_request(self, pull_request): return self._get_instance(PullRequest, pull_request) - def get_all(self, repo): - repo = self._get_repo(repo) - return PullRequest.query()\ - .filter(PullRequest.other_repo == repo)\ - .order_by(PullRequest.created_on.desc())\ - .all() + def get_all(self, repo_name, from_=False, closed=False): + """Get all PRs for repo. + Default is all PRs to the repo, PRs from the repo if from_. + Closed PRs are only included if closed is true.""" + repo = self._get_repo(repo_name) + q = PullRequest.query() + if from_: + q = q.filter(PullRequest.org_repo == repo) + else: + q = q.filter(PullRequest.other_repo == repo) + if not closed: + q = q.filter(PullRequest.status != PullRequest.STATUS_CLOSED) + return q.order_by(PullRequest.created_on.desc()).all() def create(self, created_by, org_repo, org_ref, other_repo, other_ref, revisions, reviewers, title, description=None):
--- a/rhodecode/templates/base/base.html Tue Jun 04 14:01:57 2013 +0200 +++ b/rhodecode/templates/base/base.html Wed Jun 05 01:16:42 2013 +0200 @@ -160,7 +160,7 @@ </ul> </li> <li ${is_current('showpullrequest')}> - <a href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}" title="${_('Show Pull Requests')}" class="pull-request">${_('Pull Requests')} + <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')} %if c.repository_pull_requests: <span>${c.repository_pull_requests}</span> %endif
--- a/rhodecode/templates/pullrequests/pullrequest_data.html Tue Jun 04 14:01:57 2013 +0200 +++ b/rhodecode/templates/pullrequests/pullrequest_data.html Wed Jun 05 01:16:42 2013 +0200 @@ -4,7 +4,7 @@ <div class="pr ${'pr-closed' if pr.is_closed() else ''}"> <div class="pr-title"> <img src="${h.url('/images/icons/flag_status_%s.png' % str(pr.last_review_status))}" /> - <a href="${h.url('pullrequest_show',repo_name=c.repo_name,pull_request_id=pr.pull_request_id)}"> + <a href="${h.url('pullrequest_show',repo_name=pr.other_repo.repo_name,pull_request_id=pr.pull_request_id)}"> ${_('Pull request #%s opened by %s on %s') % (pr.pull_request_id, pr.author.full_name, h.fmt_date(pr.created_on))} </a> %if pr.is_closed():
--- a/rhodecode/templates/pullrequests/pullrequest_show_all.html Tue Jun 04 14:01:57 2013 +0200 +++ b/rhodecode/templates/pullrequests/pullrequest_show_all.html Wed Jun 05 01:16:42 2013 +0200 @@ -5,7 +5,11 @@ </%def> <%def name="breadcrumbs_links()"> - ${_('Pull requests')} +%if c.from_: + ${_('Pull requests from %s') % c.repo_name} +%else: + ${_('Pull requests to %s') % c.repo_name} +%endif </%def> <%def name="page_nav()"> @@ -20,7 +24,27 @@ <div class="title"> ${self.breadcrumbs()} </div> + + <div style="margin: 0 20px"> + <div> + %if c.from_: + ${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))} + %else: + ${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))} + %endif + </div> + + <div> + %if c.closed: + ${h.link_to(_('Hide closed pull requests'), h.url('pullrequest_show_all',repo_name=c.repo_name,from_=c.from_))} + %else: + ${h.link_to(_('Show closed pull requests too'), h.url('pullrequest_show_all',repo_name=c.repo_name,from_=c.from_,closed=1))} + %endif + </div> + </div> + ${c.pullrequest_data} + </div> </%def>