diff --git a/tailbone/views/batch/core.py b/tailbone/views/batch/core.py index 65221233..5a786c82 100644 --- a/tailbone/views/batch/core.py +++ b/tailbone/views/batch/core.py @@ -1312,7 +1312,7 @@ class BatchMasterView(MasterView): def get_row_csv_fields(self): fields = super(BatchMasterView, self).get_row_csv_fields() fields = [field for field in fields - if field != 'removed' and not field.endswith('uuid')] + if field not in ('uuid', 'batch_uuid', 'removed')] return fields def get_row_results_csv_filename(self, batch): diff --git a/tailbone/views/batch/pricing.py b/tailbone/views/batch/pricing.py index 63221339..e569a001 100644 --- a/tailbone/views/batch/pricing.py +++ b/tailbone/views/batch/pricing.py @@ -165,6 +165,31 @@ class PricingBatchView(BatchMasterView): url = self.request.route_url('vendors.view', uuid=vendor.uuid) return tags.link_to(text, url) + def get_row_csv_fields(self): + fields = super(PricingBatchView, self).get_row_csv_fields() + + if 'vendor_uuid' in fields: + i = fields.index('vendor_uuid') + fields.insert(i + 1, 'vendor_id') + fields.insert(i + 2, 'vendor_abbreviation') + fields.insert(i + 3, 'vendor_name') + else: + fields.append('vendor_id') + fields.append('vendor_abbreviation') + fields.append('vendor_name') + + return fields + + def get_row_csv_row(self, row, fields): + csvrow = super(PricingBatchView, self).get_row_csv_row(row, fields) + + vendor = row.vendor + csvrow['vendor_id'] = vendor.id if vendor else None + csvrow['vendor_abbreviation'] = vendor.abbreviation if vendor else None + csvrow['vendor_name'] = vendor.name if vendor else None + + return csvrow + def includeme(config): PricingBatchView.defaults(config)