From d61d9cc574856cd64e89a5c772bb1f2de529171f Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 17 Dec 2018 22:35:56 -0600 Subject: [PATCH] Add ability to make new pricing batch from input data file --- tailbone/views/batch/pricing.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tailbone/views/batch/pricing.py b/tailbone/views/batch/pricing.py index 39ef84e0..17faaf58 100644 --- a/tailbone/views/batch/pricing.py +++ b/tailbone/views/batch/pricing.py @@ -44,7 +44,8 @@ class PricingBatchView(BatchMasterView): route_prefix = 'batch.pricing' url_prefix = '/batches/pricing' template_prefix = '/batch/pricing' - creatable = False + creatable = True + downloadable = True bulk_deletable = True rows_editable = True rows_bulk_deletable = True @@ -68,6 +69,7 @@ class PricingBatchView(BatchMasterView): form_fields = [ 'id', + 'input_filename', 'description', 'min_diff_threshold', 'min_diff_percent', @@ -136,6 +138,20 @@ class PricingBatchView(BatchMasterView): f.set_type('min_diff_threshold', 'currency') + # input_filename + if self.creating: + f.set_type('input_filename', 'file') + else: + f.set_readonly('input_filename') + f.set_renderer('input_filename', self.render_downloadable_file) + + def get_batch_kwargs(self, batch, mobile=False): + kwargs = super(PricingBatchView, self).get_batch_kwargs(batch, mobile=mobile) + kwargs['min_diff_threshold'] = batch.min_diff_threshold + kwargs['min_diff_percent'] = batch.min_diff_percent + kwargs['calculate_for_manual'] = batch.calculate_for_manual + return kwargs + def configure_row_grid(self, g): super(PricingBatchView, self).configure_row_grid(g)