mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +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([
|
@route([
|
||||||
'/runbot/branch/<model("runbot.branch"):branch>',
|
'/runbot/branch/<model("runbot.branch"):branch>',
|
||||||
|
'/runbot/branch/<model("runbot.branch"):branch>/page/<int:page>'
|
||||||
], website=True, auth='public', type='http', sitemap=False)
|
], 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]
|
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]
|
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 = {
|
context = {
|
||||||
'branch': branch,
|
'branch': branch,
|
||||||
'project': branch.remote_id.repo_id.project_id,
|
'project': branch.remote_id.repo_id.project_id,
|
||||||
'title': 'Branch %s' % branch.name,
|
'title': 'Branch %s' % branch.name,
|
||||||
'pr_branch': pr_branch,
|
'pr_branch': pr_branch,
|
||||||
'branch_pr': branch_pr
|
'branch_pr': branch_pr,
|
||||||
|
'reflog_ids': reflog_ids,
|
||||||
|
'pager': pager,
|
||||||
}
|
}
|
||||||
|
|
||||||
return request.render('runbot.branch', context)
|
return request.render('runbot.branch', context)
|
||||||
|
@ -27,13 +27,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Bundle:</td>
|
<td>Bundle:</td>
|
||||||
<td>
|
<td>
|
||||||
<small>
|
<a t-attf-href="/runbot/bundle/{{branch.bundle_id.id}}" t-esc="branch.bundle_id.name" title="View Bundle Details"/>
|
||||||
<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>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<t t-if="branch.is_pr">
|
<t t-if="branch.is_pr">
|
||||||
@ -57,6 +51,9 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</t>
|
</t>
|
||||||
</table>
|
</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;">
|
<table t-if="branch.reflog_ids" class="table table-condensed table-stripped" style="table-layout: initial;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -67,10 +64,10 @@
|
|||||||
<th>Subject</th>
|
<th>Subject</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr t-foreach='branch.reflog_ids' t-as='reflog'>
|
<tr t-foreach='reflog_ids' t-as='reflog'>
|
||||||
<td t-esc="reflog.date"/>
|
<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><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.author"/>
|
||||||
<td t-esc="reflog.commit_id.subject"/>
|
<td t-esc="reflog.commit_id.subject"/>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user