3
0
Fork 0

fix: improve rendering for batch row status

This commit is contained in:
Lance Edgar 2025-01-02 23:14:10 -06:00
parent 86ffb5d58f
commit 5cec585fdf
2 changed files with 17 additions and 1 deletions

View file

@ -53,7 +53,7 @@ class BatchMasterView(MasterView):
labels = {
'id': "Batch ID",
'status_code': "Batch Status",
'status_code': "Status",
}
sort_defaults = ('id', 'desc')
@ -62,6 +62,10 @@ class BatchMasterView(MasterView):
rows_title = "Batch Rows"
rows_sort_defaults = 'sequence'
row_labels = {
'status_code': "Status",
}
def __init__(self, request, context=None):
super().__init__(request, context=context)
self.batch_handler = self.get_batch_handler()
@ -381,6 +385,12 @@ class BatchMasterView(MasterView):
g.set_label('sequence', "Seq.", column_only=True)
g.set_renderer('status_code', self.render_row_status)
def render_row_status(self, row, key, value):
""" """
return row.STATUS.get(value, value)
##############################
# configuration
##############################

View file

@ -367,6 +367,12 @@ class TestBatchMasterView(WebTestCase):
self.assertIn('sequence', grid.labels)
self.assertEqual(grid.labels['sequence'], "Seq.")
def test_render_row_status(self):
with patch.object(mod.BatchMasterView, 'get_batch_handler', return_value=None):
view = self.make_view()
row = MagicMock(foo=1, STATUS={1: 'bar'})
self.assertEqual(view.render_row_status(row, 'foo', 1), 'bar')
def test_defaults(self):
# nb. coverage only
with patch.object(mod.BatchMasterView, 'model_class', new=MockBatch, create=True):