feat: add basic support for rows grid for master, batch views
This commit is contained in:
parent
5006c97b4b
commit
e3beb9953d
5 changed files with 573 additions and 11 deletions
|
@ -50,6 +50,10 @@ class BatchMasterView(MasterView):
|
|||
|
||||
sort_defaults = ('id', 'desc')
|
||||
|
||||
has_rows = True
|
||||
rows_title = "Batch Rows"
|
||||
rows_sort_defaults = 'sequence'
|
||||
|
||||
def __init__(self, request, context=None):
|
||||
super().__init__(request, context=context)
|
||||
self.batch_handler = self.get_batch_handler()
|
||||
|
@ -253,3 +257,33 @@ class BatchMasterView(MasterView):
|
|||
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
##############################
|
||||
# row methods
|
||||
##############################
|
||||
|
||||
@classmethod
|
||||
def get_row_model_class(cls):
|
||||
""" """
|
||||
if hasattr(cls, 'row_model_class'):
|
||||
return cls.row_model_class
|
||||
|
||||
Batch = cls.get_model_class()
|
||||
return Batch.__row_class__
|
||||
|
||||
def get_row_grid_data(self, batch):
|
||||
"""
|
||||
Returns the base query for the batch
|
||||
:attr:`~wuttjamaican:wuttjamaican.db.model.batch.BatchMixin.rows`
|
||||
data.
|
||||
"""
|
||||
BatchRow = self.get_row_model_class()
|
||||
query = self.Session.query(BatchRow)\
|
||||
.filter(BatchRow.batch == batch)
|
||||
return query
|
||||
|
||||
def configure_row_grid(self, g):
|
||||
""" """
|
||||
super().configure_row_grid(g)
|
||||
|
||||
g.set_label('sequence', "Seq.", column_only=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue