mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] runbot: improve reflogs list on branch page
Sort the reflogs in reverse and adds a pager.
This commit is contained in:
parent
219df21d99
commit
011d5245ae
@ -352,16 +352,27 @@ class Runbot(Controller):
|
||||
|
||||
@route([
|
||||
'/runbot/branch/<model("runbot.branch"):branch>',
|
||||
'/runbot/branch/<model("runbot.branch"):branch>/page/<int:page>'
|
||||
], website=True, auth='public', type='http', sitemap=False)
|
||||
def branch(self, branch=None, **kwargs):
|
||||
def branch(self, branch=None, page=1, limit=30, **kwargs):
|
||||
pr_branch = branch.bundle_id.branch_ids.filtered(lambda rec: not rec.is_pr and rec.id != branch.id and rec.remote_id.repo_id == branch.remote_id.repo_id)[:1]
|
||||
branch_pr = branch.bundle_id.branch_ids.filtered(lambda rec: rec.is_pr and rec.id != branch.id and rec.remote_id.repo_id == branch.remote_id.repo_id)[:1]
|
||||
reflog_count = len(branch.reflog_ids)
|
||||
pager = request.website.pager(
|
||||
url=f'/runbot/branch/{branch.id}',
|
||||
total=reflog_count,
|
||||
page=page,
|
||||
step=30,
|
||||
)
|
||||
reflog_ids = branch.reflog_ids.sorted(reverse=True)[pager.get('offset', 0):pager.get('offset', 0) + limit]
|
||||
context = {
|
||||
'branch': branch,
|
||||
'project': branch.remote_id.repo_id.project_id,
|
||||
'title': 'Branch %s' % branch.name,
|
||||
'pr_branch': pr_branch,
|
||||
'branch_pr': branch_pr
|
||||
'branch_pr': branch_pr,
|
||||
'reflog_ids': reflog_ids,
|
||||
'pager': pager,
|
||||
}
|
||||
|
||||
return request.render('runbot.branch', context)
|
||||
|
@ -27,13 +27,7 @@
|
||||
<tr>
|
||||
<td>Bundle:</td>
|
||||
<td>
|
||||
<small>
|
||||
<div class="btn-toolbar mb-1" role="toolbar">
|
||||
<div class="btn-group btn-group-ssm w-100" role="group">
|
||||
<a t-attf-href="/runbot/bundle/{{branch.bundle_id.id}}" t-esc="branch.bundle_id.name" class="btn btn-default text-left" title="View Bundle Details"/>
|
||||
</div>
|
||||
</div>
|
||||
</small>
|
||||
<a t-attf-href="/runbot/bundle/{{branch.bundle_id.id}}" t-esc="branch.bundle_id.name" title="View Bundle Details"/>
|
||||
</td>
|
||||
</tr>
|
||||
<t t-if="branch.is_pr">
|
||||
@ -57,6 +51,9 @@
|
||||
</tr>
|
||||
</t>
|
||||
</table>
|
||||
<span class="pull-right">
|
||||
<t t-call="website.pager" />
|
||||
</span>
|
||||
<table t-if="branch.reflog_ids" class="table table-condensed table-stripped" style="table-layout: initial;">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -67,10 +64,10 @@
|
||||
<th>Subject</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr t-foreach='branch.reflog_ids' t-as='reflog'>
|
||||
<td t-esc="reflog.date"/>
|
||||
<tr t-foreach='reflog_ids' t-as='reflog'>
|
||||
<td><span class="text-nowrap" t-esc="reflog.date"/></td>
|
||||
<td><a t-attf-href="/runbot/commit/{{reflog.commit_id.id}}" t-esc="reflog.commit_id.name"/></td>
|
||||
<td t-esc="reflog.commit_id.date"/>
|
||||
<td><span class="text-nowrap" t-esc="reflog.commit_id.date"/></td>
|
||||
<td t-esc="reflog.commit_id.author"/>
|
||||
<td t-esc="reflog.commit_id.subject"/>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user