Let batch views allow or deny "execute results" option
This commit is contained in:
parent
277d98ae2c
commit
a7d8cfcdbb
|
@ -1,68 +0,0 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/batch/index.mako" />
|
||||
|
||||
<%def name="extra_javascript()">
|
||||
${parent.extra_javascript()}
|
||||
<script type="text/javascript">
|
||||
|
||||
var has_execution_options = ${'true' if master.has_execution_options(batch) else 'false'};
|
||||
|
||||
$(function() {
|
||||
|
||||
$('#execute-results-button').click(function() {
|
||||
var form = $('form[name="execute-results"]');
|
||||
if (has_execution_options) {
|
||||
$('#execution-options-dialog').dialog({
|
||||
title: "Execution Options",
|
||||
width: 500,
|
||||
height: 300,
|
||||
modal: true,
|
||||
buttons: [
|
||||
{
|
||||
text: "Execute",
|
||||
click: function(event) {
|
||||
dialog_button(event).button('option', 'label', "Executing, please wait...").button('disable');
|
||||
form.submit();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "Cancel",
|
||||
click: function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
} else {
|
||||
$(this).button('option', 'label', "Executing, please wait...").button('disable');
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
<%def name="grid_tools()">
|
||||
% if request.has_perm('batch.handheld.execute_results'):
|
||||
<button type="button" id="execute-results-button">Execute Results</button>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
||||
<div id="execution-options-dialog" style="display: none;">
|
||||
${h.form(url('{}.execute_results'.format(route_prefix)), name='execute-results')}
|
||||
${h.csrf_token(request)}
|
||||
<br />
|
||||
<p>
|
||||
Please be advised, you are about to execute multiple batches! They will
|
||||
be aggregated and treated as a single data source, during execution.
|
||||
</p>
|
||||
<br />
|
||||
% if master.has_execution_options(batch):
|
||||
${rendered_execution_options|n}
|
||||
% endif
|
||||
${h.end_form()}
|
||||
</div>
|
|
@ -1,4 +1,71 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/master/index.mako" />
|
||||
|
||||
<%def name="extra_javascript()">
|
||||
${parent.extra_javascript()}
|
||||
% if master.results_executable and request.has_perm('{}.execute_results'.format(permission_prefix)):
|
||||
<script type="text/javascript">
|
||||
|
||||
var has_execution_options = ${'true' if master.has_execution_options(batch) else 'false'};
|
||||
|
||||
$(function() {
|
||||
|
||||
$('#execute-results-button').click(function() {
|
||||
var form = $('form[name="execute-results"]');
|
||||
if (has_execution_options) {
|
||||
$('#execution-options-dialog').dialog({
|
||||
title: "Execution Options",
|
||||
width: 500,
|
||||
height: 300,
|
||||
modal: true,
|
||||
buttons: [
|
||||
{
|
||||
text: "Execute",
|
||||
click: function(event) {
|
||||
dialog_button(event).button('option', 'label', "Executing, please wait...").button('disable');
|
||||
form.submit();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "Cancel",
|
||||
click: function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
} else {
|
||||
$(this).button('option', 'label', "Executing, please wait...").button('disable');
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
<%def name="grid_tools()">
|
||||
% if master.results_executable and request.has_perm('{}.execute_results'.format(permission_prefix)):
|
||||
<button type="button" id="execute-results-button">Execute Results</button>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
${parent.body()}
|
||||
|
||||
% if master.results_executable and master.has_execution_options(batch) and request.has_perm('{}.execute_results'.format(permission_prefix)):
|
||||
<div id="execution-options-dialog" style="display: none;">
|
||||
${h.form(url('{}.execute_results'.format(route_prefix)), name='execute-results')}
|
||||
${h.csrf_token(request)}
|
||||
<br />
|
||||
<p>
|
||||
Please be advised, you are about to execute multiple batches!
|
||||
</p>
|
||||
<br />
|
||||
% if master.has_execution_options(batch):
|
||||
${rendered_execution_options|n}
|
||||
% endif
|
||||
${h.end_form()}
|
||||
</div>
|
||||
% endif
|
||||
|
|
|
@ -68,6 +68,7 @@ class BatchMasterView(MasterView):
|
|||
edit_with_rows = False
|
||||
cloneable = False
|
||||
executable = True
|
||||
results_executable = False
|
||||
supports_mobile = True
|
||||
mobile_filterable = True
|
||||
mobile_rows_viewable = True
|
||||
|
@ -986,11 +987,12 @@ class BatchMasterView(MasterView):
|
|||
permission='{}.edit'.format(permission_prefix))
|
||||
|
||||
# execute (multiple) batch results
|
||||
config.add_route('{}.execute_results'.format(route_prefix), '{}/execute-results'.format(url_prefix))
|
||||
config.add_view(cls, attr='execute_results', route_name='{}.execute_results'.format(route_prefix),
|
||||
permission='{}.execute_multiple'.format(permission_prefix))
|
||||
config.add_tailbone_permission(permission_prefix, '{}.execute_multiple'.format(permission_prefix),
|
||||
"Execute multiple {}".format(model_title_plural))
|
||||
if cls.results_executable:
|
||||
config.add_route('{}.execute_results'.format(route_prefix), '{}/execute-results'.format(url_prefix))
|
||||
config.add_view(cls, attr='execute_results', route_name='{}.execute_results'.format(route_prefix),
|
||||
permission='{}.execute_multiple'.format(permission_prefix))
|
||||
config.add_tailbone_permission(permission_prefix, '{}.execute_multiple'.format(permission_prefix),
|
||||
"Execute multiple {}".format(model_title_plural))
|
||||
|
||||
|
||||
class FileBatchMasterView(BatchMasterView):
|
||||
|
|
|
@ -79,6 +79,7 @@ class HandheldBatchView(FileBatchMasterView):
|
|||
url_prefix = '/batch/handheld'
|
||||
execution_options_schema = ExecutionOptions
|
||||
editable = False
|
||||
results_executable = True
|
||||
|
||||
model_row_class = model.HandheldBatchRow
|
||||
rows_creatable = False
|
||||
|
|
|
@ -49,6 +49,7 @@ class LabelBatchView(BatchMasterView):
|
|||
rows_editable = True
|
||||
rows_bulk_deletable = True
|
||||
cloneable = True
|
||||
results_executable = True
|
||||
|
||||
row_grid_columns = [
|
||||
'sequence',
|
||||
|
|
Loading…
Reference in a new issue