Add vendor id, name to row CSV download for pricing batch
This commit is contained in:
parent
f7e549b5fd
commit
de6275003e
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue