Add vendor id, name to row CSV download for pricing batch
This commit is contained in:
		
							parent
							
								
									f7e549b5fd
								
							
						
					
					
						commit
						de6275003e
					
				
					 2 changed files with 26 additions and 1 deletions
				
			
		| 
						 | 
					@ -1312,7 +1312,7 @@ class BatchMasterView(MasterView):
 | 
				
			||||||
    def get_row_csv_fields(self):
 | 
					    def get_row_csv_fields(self):
 | 
				
			||||||
        fields = super(BatchMasterView, self).get_row_csv_fields()
 | 
					        fields = super(BatchMasterView, self).get_row_csv_fields()
 | 
				
			||||||
        fields = [field for field in 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
 | 
					        return fields
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_row_results_csv_filename(self, batch):
 | 
					    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)
 | 
					        url = self.request.route_url('vendors.view', uuid=vendor.uuid)
 | 
				
			||||||
        return tags.link_to(text, url)
 | 
					        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):
 | 
					def includeme(config):
 | 
				
			||||||
    PricingBatchView.defaults(config)
 | 
					    PricingBatchView.defaults(config)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue