fix: improve rendering for batch row status
This commit is contained in:
parent
86ffb5d58f
commit
5cec585fdf
|
@ -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
|
||||
##############################
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue