Try to keep batch status updated; display it for handheld batches

seems a little hacky but hoping it's safe at least
This commit is contained in:
Lance Edgar 2017-06-21 13:23:59 -05:00
parent 83dbf405f6
commit 1fc3133f8e
2 changed files with 12 additions and 0 deletions

View file

@ -150,6 +150,7 @@ class BatchMasterView(MasterView):
g.created_by.set(label="Created by", renderer=forms.renderers.UserFieldRenderer) g.created_by.set(label="Created by", renderer=forms.renderers.UserFieldRenderer)
g.cognized_by.set(renderer=forms.renderers.UserFieldRenderer) g.cognized_by.set(renderer=forms.renderers.UserFieldRenderer)
g.rowcount.set(label="Rows") g.rowcount.set(label="Rows")
g.status_code.set(label="Status", renderer=StatusRenderer(self.model_class.STATUS))
g.executed_by.set(label="Executed by", renderer=forms.renderers.UserFieldRenderer) g.executed_by.set(label="Executed by", renderer=forms.renderers.UserFieldRenderer)
def configure_grid(self, g): def configure_grid(self, g):
@ -179,6 +180,7 @@ class BatchMasterView(MasterView):
readonly=True) readonly=True)
fs.cognized_by.set(label="Cognized by", renderer=forms.renderers.UserFieldRenderer) fs.cognized_by.set(label="Cognized by", renderer=forms.renderers.UserFieldRenderer)
fs.rowcount.set(label="Row Count") fs.rowcount.set(label="Row Count")
fs.status_code.set(label="Status", renderer=StatusRenderer(self.model_class.STATUS))
fs.executed_by.set(label="Executed by", renderer=forms.renderers.UserFieldRenderer) fs.executed_by.set(label="Executed by", renderer=forms.renderers.UserFieldRenderer)
fs.notes.set(renderer=fa.TextAreaFieldRenderer, size=(80, 10)) fs.notes.set(renderer=fa.TextAreaFieldRenderer, size=(80, 10))
@ -513,6 +515,7 @@ class BatchMasterView(MasterView):
batch = session.query(self.model_class).get(batch_uuid) batch = session.query(self.model_class).get(batch_uuid)
try: try:
self.handler.populate(batch, progress=progress) self.handler.populate(batch, progress=progress)
self.handler.refresh_batch_status(batch)
except Exception as error: except Exception as error:
session.rollback() session.rollback()
log.warning("batch pre-fill failed: {}".format(batch), exc_info=True) log.warning("batch pre-fill failed: {}".format(batch), exc_info=True)
@ -721,6 +724,7 @@ class BatchMasterView(MasterView):
if not row: if not row:
raise httpexceptions.HTTPNotFound() raise httpexceptions.HTTPNotFound()
row.removed = True row.removed = True
self.handler.refresh_batch_status(row.batch)
return self.redirect(self.get_action_url('view', self.get_parent(row))) return self.redirect(self.get_action_url('view', self.get_parent(row)))
def bulk_delete_rows(self): def bulk_delete_rows(self):

View file

@ -94,10 +94,17 @@ class HandheldBatchView(FileBatchMasterView):
g.created, g.created,
g.created_by, g.created_by,
g.rowcount, g.rowcount,
g.status_code,
g.executed, g.executed,
], ],
readonly=True) readonly=True)
def row_attrs(self, batch, i):
attrs = {}
if batch.status_code != batch.STATUS_OK:
attrs['class_'] = 'notice'
return attrs
def configure_fieldset(self, fs): def configure_fieldset(self, fs):
fs.device_type.set(renderer=forms.renderers.EnumFieldRenderer(enum.HANDHELD_DEVICE_TYPE)) fs.device_type.set(renderer=forms.renderers.EnumFieldRenderer(enum.HANDHELD_DEVICE_TYPE))
@ -119,6 +126,7 @@ class HandheldBatchView(FileBatchMasterView):
fs.created, fs.created,
fs.created_by, fs.created_by,
fs.rowcount, fs.rowcount,
fs.status_code,
fs.executed, fs.executed,
fs.executed_by, fs.executed_by,
]) ])