Tweak behavior when executing handheld batch results

redirect to final batch when done, try to warn user a bit
This commit is contained in:
Lance Edgar 2017-06-22 01:02:03 -05:00
parent 0d448fe6c5
commit 17017adde8
3 changed files with 17 additions and 2 deletions

View file

@ -53,6 +53,12 @@ ${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!&nbsp; They will
be aggregated and treated as a single data source, during execution.
</p>
<br />
% if master.has_execution_options:
${rendered_execution_options|n}
% endif

View file

@ -880,7 +880,7 @@ class BatchMasterView(MasterView):
# If anything goes wrong, rollback and log the error etc.
except Exception as error:
session.rollback()
log.exception("execution failed for batch: {}".format(batch))
log.exception("execution failed for batch results")
session.close()
if progress:
progress.session.load()
@ -899,16 +899,21 @@ class BatchMasterView(MasterView):
# TODO: this doesn't always work...?
self.request.session.flash("{} {} were executed".format(
len(batches), self.get_model_title_plural()))
success_url = self.get_execute_results_success_url(result, **kwargs)
else:
session.rollback()
success_url = self.get_index_url()
session.close()
if progress:
progress.session.load()
progress.session['complete'] = True
progress.session['success_url'] = self.get_index_url()
progress.session['success_url'] = success_url
progress.session.save()
def get_execute_results_success_url(self, result, **kwargs):
return self.get_index_url()
def csv(self):
"""
Download batch data as CSV.

View file

@ -199,6 +199,10 @@ class HandheldBatchView(FileBatchMasterView):
return self.request.route_url('labels.batch.view', uuid=result.uuid)
return super(HandheldBatchView, self).get_execute_success_url(batch)
def get_execute_results_success_url(self, result, **kwargs):
batch = result
return self.get_execute_success_url(batch, result, **kwargs)
def includeme(config):
HandheldBatchView.defaults(config)