Refactor / cleanup v2 batch master
also remove old/unused logic from v1 batch master
This commit is contained in:
parent
df1c0b0b5e
commit
951057d8c2
|
@ -134,50 +134,6 @@ class BatchMasterView(MasterView):
|
||||||
def get_instance_title(self, batch):
|
def get_instance_title(self, batch):
|
||||||
return batch.id_str or unicode(batch)
|
return batch.id_str or unicode(batch)
|
||||||
|
|
||||||
def _preconfigure_grid(self, g):
|
|
||||||
"""
|
|
||||||
Apply some commonly-useful pre-configuration to the main batch grid.
|
|
||||||
"""
|
|
||||||
g.joiners['created_by'] = lambda q: q.join(model.User,
|
|
||||||
model.User.uuid == self.model_class.created_by_uuid)
|
|
||||||
g.joiners['executed_by'] = lambda q: q.outerjoin(model.User,
|
|
||||||
model.User.uuid == self.model_class.executed_by_uuid)
|
|
||||||
|
|
||||||
g.filters['id'].label = "Batch ID"
|
|
||||||
g.filters['executed'].default_active = True
|
|
||||||
g.filters['executed'].default_verb = 'is_null'
|
|
||||||
|
|
||||||
# TODO: in some cases grid has no sorters yet..e.g. when building query for bulk-delete
|
|
||||||
if hasattr(g, 'sorters'):
|
|
||||||
g.sorters['created_by'] = g.make_sorter(model.User.username)
|
|
||||||
g.sorters['executed_by'] = g.make_sorter(model.User.username)
|
|
||||||
|
|
||||||
g.default_sortkey = 'created'
|
|
||||||
g.default_sortdir = 'desc'
|
|
||||||
|
|
||||||
g.id.set(label="ID", renderer=forms.renderers.BatchIDFieldRenderer)
|
|
||||||
g.created_by.set(label="Created by", renderer=forms.renderers.UserFieldRenderer)
|
|
||||||
g.cognized_by.set(renderer=forms.renderers.UserFieldRenderer)
|
|
||||||
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)
|
|
||||||
|
|
||||||
def configure_grid(self, g):
|
|
||||||
"""
|
|
||||||
Apply final configuration to the main batch grid. Custom batch views
|
|
||||||
are encouraged to override this method.
|
|
||||||
"""
|
|
||||||
g.configure(
|
|
||||||
include=[
|
|
||||||
g.id,
|
|
||||||
g.created,
|
|
||||||
g.created_by,
|
|
||||||
g.rowcount,
|
|
||||||
g.executed,
|
|
||||||
g.executed_by,
|
|
||||||
],
|
|
||||||
readonly=True)
|
|
||||||
|
|
||||||
def get_mobile_data(self, session=None):
|
def get_mobile_data(self, session=None):
|
||||||
return super(BatchMasterView, self).get_mobile_data(session=session)\
|
return super(BatchMasterView, self).get_mobile_data(session=session)\
|
||||||
.order_by(self.model_class.id.desc())
|
.order_by(self.model_class.id.desc())
|
||||||
|
@ -682,18 +638,6 @@ class BatchMasterView(MasterView):
|
||||||
def get_row_instance_title(self, row):
|
def get_row_instance_title(self, row):
|
||||||
return "Row {}".format(row.sequence)
|
return "Row {}".format(row.sequence)
|
||||||
|
|
||||||
def _preconfigure_row_grid(self, g):
|
|
||||||
|
|
||||||
g.filters['status_code'].label = "Status"
|
|
||||||
g.filters['status_code'].set_value_renderer(grids.filters.EnumValueRenderer(self.model_row_class.STATUS))
|
|
||||||
|
|
||||||
g.default_sortkey = 'sequence'
|
|
||||||
|
|
||||||
g.sequence.set(label="Seq.")
|
|
||||||
g.status_code.set(label="Status",
|
|
||||||
renderer=StatusRenderer(self.model_row_class.STATUS))
|
|
||||||
|
|
||||||
|
|
||||||
hide_row_status_codes = []
|
hide_row_status_codes = []
|
||||||
|
|
||||||
def get_row_data(self, batch):
|
def get_row_data(self, batch):
|
||||||
|
@ -1082,11 +1026,6 @@ class FileBatchMasterView(BatchMasterView):
|
||||||
os.makedirs(uploads)
|
os.makedirs(uploads)
|
||||||
return uploads
|
return uploads
|
||||||
|
|
||||||
def preconfigure_grid(self, g):
|
|
||||||
super(FileBatchMasterView, self).preconfigure_grid(g)
|
|
||||||
g.created.set(label="Uploaded")
|
|
||||||
g.created_by.set(label="Uploaded by")
|
|
||||||
|
|
||||||
def _preconfigure_fieldset(self, fs):
|
def _preconfigure_fieldset(self, fs):
|
||||||
super(FileBatchMasterView, self)._preconfigure_fieldset(fs)
|
super(FileBatchMasterView, self)._preconfigure_fieldset(fs)
|
||||||
fs.created.set(label="Uploaded")
|
fs.created.set(label="Uploaded")
|
||||||
|
|
|
@ -52,17 +52,6 @@ class BatchMasterView2(MasterView2, BatchMasterView):
|
||||||
'executed_by',
|
'executed_by',
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_fallback_templates(self, template, mobile=False):
|
|
||||||
if mobile:
|
|
||||||
return [
|
|
||||||
'/mobile/newbatch/{}.mako'.format(template),
|
|
||||||
'/mobile/master/{}.mako'.format(template),
|
|
||||||
]
|
|
||||||
return [
|
|
||||||
'/newbatch/{}.mako'.format(template),
|
|
||||||
'/master/{}.mako'.format(template),
|
|
||||||
]
|
|
||||||
|
|
||||||
def configure_grid(self, g):
|
def configure_grid(self, g):
|
||||||
super(BatchMasterView2, self).configure_grid(g)
|
super(BatchMasterView2, self).configure_grid(g)
|
||||||
|
|
||||||
|
@ -122,14 +111,6 @@ class BatchMasterView2(MasterView2, BatchMasterView):
|
||||||
return HTML.tag('span', title=row.status_text, c=text)
|
return HTML.tag('span', title=row.status_text, c=text)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def make_mobile_filters(self):
|
|
||||||
"""
|
|
||||||
Returns a set of filters for the mobile grid.
|
|
||||||
"""
|
|
||||||
filters = grids.filters.GridFilterSet()
|
|
||||||
filters['status'] = MobileBatchStatusFilter(self.model_class, 'status', default_value='pending')
|
|
||||||
return filters
|
|
||||||
|
|
||||||
|
|
||||||
class FileBatchMasterView2(BatchMasterView2, FileBatchMasterView):
|
class FileBatchMasterView2(BatchMasterView2, FileBatchMasterView):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue