Improve "download rows as XLSX" for importer batch
still could be better, but at least this avoids error
This commit is contained in:
parent
b11f9f62b7
commit
33ffd7e855
|
@ -286,6 +286,30 @@ class ImporterBatchView(BatchMasterView):
|
|||
delete_query.execute()
|
||||
return self.redirect(self.get_action_url('view', batch))
|
||||
|
||||
def get_row_xlsx_fields(self):
|
||||
return [
|
||||
'sequence',
|
||||
'object_key',
|
||||
'object_str',
|
||||
'status',
|
||||
'status_code',
|
||||
'status_text',
|
||||
]
|
||||
|
||||
def get_row_xlsx_row(self, row, fields):
|
||||
xlrow = super(ImporterBatchView, self).get_row_xlsx_row(row, fields)
|
||||
|
||||
xlrow['status'] = self.enum.IMPORTER_BATCH_ROW_STATUS[row.status_code]
|
||||
|
||||
return xlrow
|
||||
|
||||
|
||||
def defaults(config, **kwargs):
|
||||
base = globals()
|
||||
|
||||
ImporterBatchView = kwargs.get('ImporterBatchView', base['ImporterBatchView'])
|
||||
ImporterBatchView.defaults(config)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
ImporterBatchView.defaults(config)
|
||||
defaults(config)
|
||||
|
|
|
@ -3850,11 +3850,17 @@ class MasterView(View):
|
|||
"""
|
||||
Return the list of row fields to be written to CSV download.
|
||||
"""
|
||||
fields = []
|
||||
mapper = orm.class_mapper(self.model_row_class)
|
||||
for prop in mapper.iterate_properties:
|
||||
if isinstance(prop, orm.ColumnProperty):
|
||||
fields.append(prop.key)
|
||||
try:
|
||||
mapper = orm.class_mapper(self.model_row_class)
|
||||
except:
|
||||
fields = self.get_row_form_fields()
|
||||
if not fields:
|
||||
fields = self.get_row_grid_columns()
|
||||
else:
|
||||
fields = []
|
||||
for prop in mapper.iterate_properties:
|
||||
if isinstance(prop, orm.ColumnProperty):
|
||||
fields.append(prop.key)
|
||||
return fields
|
||||
|
||||
def get_csv_row(self, obj, fields):
|
||||
|
|
Loading…
Reference in a new issue