mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] runbot: enable user to toggle no_build
This commit is contained in:
parent
70f4fe23a5
commit
1d5712eeaa
@ -127,7 +127,9 @@ class Runbot(Controller):
|
||||
'hosts_data': request.env['runbot.host'].search([('assigned_only', '=', False)]),
|
||||
}
|
||||
if project:
|
||||
domain = [('last_batch', '!=', False), ('project_id', '=', project.id), ('no_build', '=', False)]
|
||||
domain = [('last_batch', '!=', False), ('project_id', '=', project.id)]
|
||||
if not search:
|
||||
domain.append(('no_build', '=', False))
|
||||
|
||||
if has_pr is not None:
|
||||
domain.append(('has_pr', '=', bool(has_pr)))
|
||||
@ -641,3 +643,16 @@ class Runbot(Controller):
|
||||
def parse_log(self, ir_log, **kwargs):
|
||||
request.env['runbot.build.error']._parse_logs(ir_log)
|
||||
return werkzeug.utils.redirect('/runbot/build/%s' % ir_log.build_id.id)
|
||||
|
||||
@route(['/runbot/bundle/toogle_no_build/<int:bundle_id>/<int:value>'], type='http', auth='user', sitemap=False)
|
||||
def toogle_no_build(self, bundle_id, value, **kwargs):
|
||||
if not request.env.user.has_group('base.group_user'):
|
||||
return 'Forbidden'
|
||||
bundle = request.env['runbot.bundle'].browse(bundle_id).exists()
|
||||
if bundle.sticky or bundle.is_base:
|
||||
return 'Forbidden'
|
||||
if bundle.project_id.tmp_prefix and bundle.name.startswith(bundle.project_id.tmp_prefix):
|
||||
return 'Forbidden'
|
||||
bundle.sudo().no_build = bool(value)
|
||||
_logger.info('Bundle %s no_build set to %s by %s', bundle.name, bool(value), request.env.user.name)
|
||||
return werkzeug.utils.redirect(f'/runbot/bundle/{bundle_id}')
|
||||
|
@ -30,6 +30,26 @@
|
||||
</div>
|
||||
<div>
|
||||
<table class="table table-condensed table-responsive table-stripped">
|
||||
<tr groups="base.group_user" t-if="not bundle.sticky and not bundle.is_base">
|
||||
<t t-if="bundle.no_build">
|
||||
<td class="text-danger">Build disabled</td>
|
||||
<td>
|
||||
<a class="btn btn-primary btn-ssm"
|
||||
t-attf-href="/runbot/bundle/toogle_no_build/{{bundle.id}}/0">
|
||||
Enable builds
|
||||
</a>
|
||||
</td>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<td>Build enabled</td>
|
||||
<td>
|
||||
<a class="btn btn-secondary btn-ssm"
|
||||
t-attf-href="/runbot/bundle/toogle_no_build/{{bundle.id}}/1">
|
||||
Disable builds
|
||||
</a>
|
||||
</td>
|
||||
</t>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Version</td>
|
||||
<td>
|
||||
|
Loading…
Reference in New Issue
Block a user