diff --git a/tailbone/templates/batch/pricing/configure.mako b/tailbone/templates/batch/pricing/configure.mako new file mode 100644 index 00000000..8b5a90bb --- /dev/null +++ b/tailbone/templates/batch/pricing/configure.mako @@ -0,0 +1,22 @@ +## -*- coding: utf-8; -*- +<%inherit file="/configure.mako" /> + +<%def name="form_content()"> + +

Options

+
+ + + + Allow "future" pricing + + + +
+ + + +${parent.body()} diff --git a/tailbone/views/batch/pricing.py b/tailbone/views/batch/pricing.py index 1f054e61..18a4ea90 100644 --- a/tailbone/views/batch/pricing.py +++ b/tailbone/views/batch/pricing.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2021 Lance Edgar +# Copyright © 2010-2022 Lance Edgar # # This file is part of Rattail. # @@ -52,6 +52,7 @@ class PricingBatchView(BatchMasterView): bulk_deletable = True rows_editable = True rows_bulk_deletable = True + configurable = True labels = { 'min_diff_threshold': "Min $ Diff", @@ -62,6 +63,7 @@ class PricingBatchView(BatchMasterView): grid_columns = [ 'id', 'description', + 'start_date', 'created', 'created_by', 'rowcount', @@ -75,6 +77,7 @@ class PricingBatchView(BatchMasterView): 'id', 'input_filename', 'description', + 'start_date', 'min_diff_threshold', 'min_diff_percent', 'calculate_for_manual', @@ -147,8 +150,24 @@ class PricingBatchView(BatchMasterView): 'status_text', ] + def allow_future_pricing(self): + return self.batch_handler.allow_future() + def configure_form(self, f): super(PricingBatchView, self).configure_form(f) + app = self.get_rattail_app() + batch = f.model_instance + + if self.creating or self.editing: + if self.allow_future_pricing(): + f.set_type('start_date', 'date_jquery') + f.set_helptext('start_date', "Only set this for a \"FUTURE\" batch.") + else: + f.remove('start_date') + else: # viewing or deleting + if not self.allow_future_pricing(): + if not batch.start_date: + f.remove('start_date') f.set_type('min_diff_threshold', 'currency') @@ -349,6 +368,15 @@ class PricingBatchView(BatchMasterView): return xlrow + def configure_get_simple_settings(self): + return [ + + # options + {'section': 'rattail.batch', + 'option': 'pricing.allow_future', + 'type': bool}, + ] + def includeme(config): PricingBatchView.defaults(config) diff --git a/tailbone/views/products.py b/tailbone/views/products.py index a5706a25..6cdb001a 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -1892,14 +1892,15 @@ class ProductView(MasterView): return {'product': data} def get_supported_batches(self): + app = self.get_rattail_app() + pricing = app.get_batch_handler('pricing') return OrderedDict([ ('labels', { 'spec': self.rattail_config.get('rattail.batch', 'labels.handler', default='rattail.batch.labels:LabelBatchHandler'), }), ('pricing', { - 'spec': self.rattail_config.get('rattail.batch', 'pricing.handler', - default='rattail.batch.pricing:PricingBatchHandler'), + 'spec': pricing.get_spec(), }), ('delproduct', { 'spec': self.rattail_config.get('rattail.batch', 'delproduct.handler', @@ -2003,7 +2004,9 @@ class ProductView(MasterView): """ Return params schema for making a pricing batch. """ - return colander.SchemaNode( + app = self.get_rattail_app() + + schema = colander.SchemaNode( colander.Mapping(), colander.SchemaNode(colander.Decimal(), name='min_diff_threshold', quant='1.00', missing=colander.null, @@ -2014,6 +2017,17 @@ class ProductView(MasterView): colander.SchemaNode(colander.Boolean(), name='calculate_for_manual'), ) + pricing = app.get_batch_handler('pricing') + if pricing.allow_future(): + schema.insert(0, colander.SchemaNode( + colander.Date(), + name='start_date', + missing=colander.null, + title="Start Date (FUTURE only)", + widget=forms.widgets.JQueryDateWidget())) + + return schema + def make_batch_params_schema_delproduct(self): """ Return params schema for making a "delete products" batch.