diff --git a/tailbone/views/batch/importer.py b/tailbone/views/batch/importer.py index c16c6180..ac690f80 100644 --- a/tailbone/views/batch/importer.py +++ b/tailbone/views/batch/importer.py @@ -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) diff --git a/tailbone/views/master.py b/tailbone/views/master.py index dbe4049e..096108a6 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -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):