From c064bb275f77df0ab689b14b53658177c49d7ba7 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 2 Jan 2019 16:38:38 -0600 Subject: [PATCH] Expose `vendor_id` column in pricing batch row grid --- tailbone/views/batch/pricing.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tailbone/views/batch/pricing.py b/tailbone/views/batch/pricing.py index ce6cd672..d8790606 100644 --- a/tailbone/views/batch/pricing.py +++ b/tailbone/views/batch/pricing.py @@ -84,6 +84,7 @@ class PricingBatchView(BatchMasterView): row_labels = { 'upc': "UPC", + 'vendor_id': "Vendor ID", 'regular_unit_cost': "Reg. Cost", 'price_diff': "$ Diff", 'price_diff_percent': "% Diff", @@ -98,6 +99,7 @@ class PricingBatchView(BatchMasterView): 'brand_name', 'description', 'size', + 'vendor_id', 'discounted_unit_cost', 'old_price', 'new_price', @@ -157,10 +159,20 @@ class PricingBatchView(BatchMasterView): def configure_row_grid(self, g): super(PricingBatchView, self).configure_row_grid(g) + g.set_joiner('vendor_id', lambda q: q.outerjoin(model.Vendor)) + g.set_sorter('vendor_id', model.Vendor.id) + g.set_renderer('vendor_id', self.render_vendor_id) + g.set_type('old_price', 'currency') g.set_type('new_price', 'currency') g.set_type('price_diff', 'currency') + def render_vendor_id(self, row, field): + vendor_id = row.vendor.id if row.vendor else None + if not vendor_id: + return "" + return vendor_id + def row_grid_extra_class(self, row, i): if row.status_code == row.STATUS_CANNOT_CALCULATE_PRICE: return 'warning'