[FIX] runbot: various view fixes

- fix missing batch references on builds
- fix group on action buttons
This commit is contained in:
Xavier-Do 2021-04-09 14:44:26 +02:00 committed by Christophe Monniez
parent 57bd00672d
commit 84d9425bdc
9 changed files with 25 additions and 34 deletions

View File

@ -199,6 +199,7 @@ class BuildResult(models.Model):
parent_id = fields.Many2one('runbot.build', 'Parent Build', index=True)
parent_path = fields.Char('Parent path', index=True)
top_parent = fields.Many2one('runbot.build', compute='_compute_top_parent')
# should we add a has children stored boolean?
children_ids = fields.One2many('runbot.build', 'parent_id')
@ -252,12 +253,9 @@ class BuildResult(models.Model):
for build in self:
build.md_description = pseudo_markdown(build.description)
def _get_top_parent(self):
self.ensure_one()
build = self
while build.parent_id:
build = build.parent_id
return build
def _compute_top_parent(self):
for build in self:
build.top_parent = self.browse(int(build.parent_path.split('/')[0]))
def _get_youngest_state(self, states):
index = min([self._get_state_score(state) for state in states])

View File

@ -73,7 +73,7 @@ class BuildError(models.Model):
@api.depends('build_ids')
def _compute_bundle_ids(self):
for build_error in self:
top_parent_builds = build_error.build_ids.mapped(lambda rec: rec and rec._get_top_parent())
top_parent_builds = build_error.build_ids.mapped(lambda rec: rec and rec.top_parent)
build_error.bundle_ids = top_parent_builds.mapped('slot_ids').mapped('batch_id.bundle_id')
@api.depends('build_ids')

View File

@ -110,9 +110,8 @@ class Runbot(models.AbstractModel):
return
for build in testing_builds:
top_parent = build._get_top_parent()
if build.killable:
top_parent._ask_kill(message='Build automatically killed, new build found.')
build.top_parent._ask_kill(message='Build automatically killed, new build found.')
def _allocate_builds(self, host, nb_slots, domain=None):
if nb_slots <= 0:

View File

@ -44,7 +44,7 @@ class BuildResult(models.Model):
if exception:
bundle = False
batches = self._get_top_parent().slot_ids.mapped('batch_id')
batches = self.top_parent.slot_ids.mapped('batch_id')
if batches:
bundle = batches[0].bundle_id.id
res = {

View File

@ -13,16 +13,10 @@
</t>
</div>
</form>
<form class="form-inline" t-attf-action="/runbot/build/#{build['id']}/force" method='POST' t-if="request.params.get('ask_rebuild')" groups="runbot.group_user">
<a href='#' class="btn btn-danger" data-runbot="rebuild" t-attf-data-runbot-build="#{build['id']}">
<i class='fa fa-refresh'/>
Force Rebuild
</a>
</form>
</t>
<div class="row">
<div class="col-md-12">
<t t-set="batches" t-value="build.slot_ids.mapped('batch_id')"/>
<t t-set="batches" t-value="build.top_parent.with_context(active_test=False).slot_ids.mapped('batch_id')"/>
<t t-set="bundles" t-value="batches.mapped('bundle_id')"/>
<t t-if="batches">
<t t-if="len(bundles) == 1">
@ -55,6 +49,17 @@
<br/>
</t>
</t>
<div t-if="build.parent_id">
<b>Parent build:</b>
<a t-attf-href="/runbot/build/#{build.parent_id.id}">
<t t-esc="build.parent_id.dest"/>
</a>
<t t-if="build.orphan_result">
&amp;nbsp;
<i class="fa fa-chain-broken" title="Build result ignored for parent" />
&amp;nbsp;Orphaned build, the result does not affect parent build result
</t>
</div>
</div>
<div class="col-md-12">
<table class="table table-condensed tabel-bordered">
@ -196,17 +201,6 @@
</td>
</tr>
</table>
<p t-if="build.parent_id">
Child of
<a t-attf-href="/runbot/build/#{build.parent_id.id}">
<t t-esc="build.parent_id.dest"/>
</a>
<t t-if="build.orphan_result">
&amp;nbsp;
<i class="fa fa-chain-broken" title="Build result ignored for parent" />
&amp;nbsp;Orphaned build, the result does not affect parent build result
</t>
</p>
<table class="table table-condensed">
<tr>
<th>Date</th>

View File

@ -42,7 +42,7 @@
</div>
<div class="col"><t t-esc="build_error.responsible.name"/></div>
<div class="col">
<a groups="runbot.group_user" t-attf-href="/web/#id={{build_error.id}}&amp;view_type=form&amp;model=runbot.build.error" target="new" title="View in Backend">
<a groups="base.group_user" t-attf-href="/web/#id={{build_error.id}}&amp;view_type=form&amp;model=runbot.build.error" target="new" title="View in Backend">
<i class="fa fa-list"/>
</a>
<a t-att-href="build_error.last_seen_build_id.build_url" t-attf-title="View last affected build ({{build_error.last_seen_build_id.id}})"><i class="fa fa-external-link"/></a>
@ -116,7 +116,7 @@
</div>
<div class="col"><t t-esc="build_error.responsible.name"/></div>
<div class="col">
<a groups="runbot.group_user" t-attf-href="/web/#id={{build_error.id}}&amp;view_type=form&amp;model=runbot.build.error" target="new" title="View in Backend">
<a groups="base.group_user" t-attf-href="/web/#id={{build_error.id}}&amp;view_type=form&amp;model=runbot.build.error" target="new" title="View in Backend">
<i class="fa fa-list"/>
</a>
<a t-att-href="build_error.last_seen_build_id.build_url" t-attf-title="View last affected build ({{build_error.last_seen_build_id.id}})"><i class="fa fa-external-link"/></a>

View File

@ -14,10 +14,10 @@
<a groups="runbot.group_runbot_admin" t-attf-href="/web/#id={{bundle.id}}&amp;view_type=form&amp;model=runbot.bundle" class="btn btn-default btn-sm" target="new" title="View in Backend">
<i class="fa fa-list"/>
</a>
<a class="btn btn-default" groups="runbot.group_user" t-attf-href="/runbot/bundle/{{bundle.id}}/force" title="Force A New Batch">
<a class="btn btn-default" groups="base.group_user" t-attf-href="/runbot/bundle/{{bundle.id}}/force" title="Force A New Batch">
<i class="fa fa-refresh"/>
</a>
<a class="btn btn-default" groups="runbot.group_user" t-attf-href="/runbot/bundle/{{bundle.id}}/force/1" title="Force A New Batch with automatic rebase">
<a class="btn btn-default" groups="base.group_user" t-attf-href="/runbot/bundle/{{bundle.id}}/force/1" title="Force A New Batch with automatic rebase">
<i class="fa fa-fast-forward"/>
</a>
<t t-call="runbot.branch_copy_button"/>

View File

@ -81,7 +81,7 @@
<t t-if="status.target_url" t-esc="status.target_url.split('/')[-1]" />
</a>
</td>
<td groups="runbot.group_user">
<td groups="base.group_user">
<a t-attf-href="/runbot/commit/resend/{{status.id}}" title="Resend github status">
<i class="fa fa-repeat"/>
</a>

View File

@ -166,7 +166,7 @@
</span>
<a t-if="bu.local_state == 'running' and bu.database_ids" t-attf-href="http://{{sorted(bu.mapped('database_ids.name'))[0]}}.{{bu.host}}" class="fa fa-sign-in btn btn-info"/>
<t t-if="bu" t-call="runbot.build_menu"/>
<a t-if="not bu" groups="runbot.group_user" class="btn btn-default" title="Create build" t-attf-href="/runbot/batch/slot/{{slot.id}}/build">
<a t-if="not bu" groups="base.group_user" class="btn btn-default" title="Create build" t-attf-href="/runbot/batch/slot/{{slot.id}}/build">
<i class="fa fa-play fa-fw"/>
</a>
</div>