# HG changeset patch # User Thomas De Schampheleire # Date 2015-02-21 22:29:46 # Node ID e79993216c66aa104b9a36e516a1a703d943783a # Parent 508a49a1a02f638c7229d2209ab014df972fe310 my pullrequests: line up controller/template handling with repo pullrequests Currently, the data for 'my pullrequests' is loaded dynamically through ajax, unlike the way 'repository pullrequests' are loaded (statically). As there is no good reason to have both treated differently, and as dynamic loading of 'my pullrequests' is not really needed, rework the handling of the 'my pullrequests' page with the 'repository pullrequests' page. This includes lining up the 'show closed pull requests' checkbox/link. This also fixes issue #102 ('my pull requests' when not logged in: incorrect handling of login). diff --git a/kallithea/config/routing.py b/kallithea/config/routing.py --- a/kallithea/config/routing.py +++ b/kallithea/config/routing.py @@ -729,10 +729,6 @@ def make_map(config): '/my_pullrequests', controller='pullrequests', action='show_my', conditions=dict(method=["GET"])) - rmap.connect('my_pullrequests_data', - '/my_pullrequests_data', - controller='pullrequests', - action='show_my_data', conditions=dict(method=["GET"])) rmap.connect('pullrequest_comment', '/{repo_name:.*?}/pull-request-comment/{pull_request_id}', diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -210,17 +210,13 @@ class PullrequestsController(BaseRepoCon return render('/pullrequests/pullrequest_show_all.html') @LoginRequired() - def show_my(self): # my_account_my_pullrequests - c.show_closed = request.GET.get('pr_show_closed') - return render('/pullrequests/pullrequest_show_my.html') - @NotAnonymous() - def show_my_data(self): - c.show_closed = request.GET.get('pr_show_closed') + def show_my(self): + c.closed = request.GET.get('closed') or '' def _filter(pr): s = sorted(pr, key=lambda o: o.created_on, reverse=True) - if not c.show_closed: + if not c.closed: s = filter(lambda p: p.status != PullRequest.STATUS_CLOSED, s) return s @@ -235,7 +231,7 @@ class PullrequestsController(BaseRepoCon self.authuser.user_id)\ ) - return render('/pullrequests/pullrequest_show_my_data.html') + return render('/pullrequests/pullrequest_show_my.html') @LoginRequired() @NotAnonymous() diff --git a/kallithea/templates/pullrequests/pullrequest_show_my.html b/kallithea/templates/pullrequests/pullrequest_show_my.html --- a/kallithea/templates/pullrequests/pullrequest_show_my.html +++ b/kallithea/templates/pullrequests/pullrequest_show_my.html @@ -20,31 +20,19 @@ ${self.breadcrumbs()} -
- ## loaded via AJAX - ${_('Loading...')} +
+
+ %if c.closed: + ${h.link_to(_('Hide closed pull requests (only show open pull requests)'), h.url('my_pullrequests'))} + %else: + ${h.link_to(_('Show closed pull requests (in addition to open pull requests)'), h.url('my_pullrequests',closed=1))} + %endif +
- +
+ <%include file='pullrequest_show_my_data.html'/> +
- diff --git a/kallithea/templates/pullrequests/pullrequest_show_my_data.html b/kallithea/templates/pullrequests/pullrequest_show_my_data.html --- a/kallithea/templates/pullrequests/pullrequest_show_my_data.html +++ b/kallithea/templates/pullrequests/pullrequest_show_my_data.html @@ -1,4 +1,3 @@ -${h.checkbox('show_closed',checked="checked" if c.show_closed else "", label=_('Show closed pull requests (in addition to open pull requests)'))}
${_('Pull Requests Created by Me')}