Changeset - e79993216c66
[Not reviewed]
default
0 4 0
Thomas De Schampheleire - 11 years ago 2015-02-21 22:29:46
thomas.de_schampheleire@alcatel-lucent.com
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).
4 files changed with 15 insertions and 36 deletions:
0 comments (0 inline, 0 general)
kallithea/config/routing.py
Show inline comments
 
@@ -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}',
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -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()
kallithea/templates/pullrequests/pullrequest_show_my.html
Show inline comments
 
@@ -20,31 +20,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>
kallithea/templates/pullrequests/pullrequest_show_my_data.html
Show inline comments
 
${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:
0 comments (0 inline, 0 general)