[PATCH 3 of 3] my pullrequests: line up internal handling with repository pullrequests
Thomas De Schampheleire
patrickdepinguin at gmail.com
Sat Feb 21 16:48:15 EST 2015
# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schampheleire at alcatel-lucent.com>
# Date 1424554186 -3600
# Sat Feb 21 22:29:46 2015 +0100
# Node ID 8ed5da3e4184defac92036cd8f19aa7cb61ba0fb
# Parent 0728fc3662d27756523ae0d03b91caffb1587ad9
my pullrequests: line up internal handling with repository pullrequests
Currently, the data for 'my pullrequests' are 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.
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 @@
'/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
@@ -207,17 +207,12 @@
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
@@ -232,7 +227,7 @@
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
@@ -23,31 +23,19 @@
${self.breadcrumbs()}
</div>
- <div id="pullrequests_container" class="table">
- ## loaded via AJAX
- ${_('Loading...')}
+ <div style="margin: 0 20px">
+ <div>
+ %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
+ </div>
</div>
-<script type="text/javascript">
-pyroutes.register('my_pullrequests_data', "${url('my_pullrequests_data')}", []);
-
-var show_pullrequests = function(e){
-
- var url = pyroutes.url('my_pullrequests_data');
- if ($('#show_closed').prop('checked')) {
- var url = pyroutes.url('my_pullrequests_data', {'pr_show_closed': '1'});
- }
- asynchtml(url, $('#pullrequests_container'), function(){
- // new #show_closed has just been loaded
- $('#show_closed').change(function (e) {
- show_pullrequests(e);
- });
- });
-}
-show_pullrequests()
-
-</script>
+ <div id="pullrequests_container" class="table">
+ <%include file='pullrequest_show_my_data.html'/>
+ </div>
</div>
-
</%def>
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)'))}
<div class="pullrequests_section_head">${_('Pull Requests Created by Me')}</div>
<ul>
%if c.my_pull_requests:
More information about the kallithea-general
mailing list