Remove some deprecated batch handler methods

This commit is contained in:
Lance Edgar 2017-05-18 11:56:55 -05:00
parent 75e6a550d0
commit ca06c921cb
10 changed files with 17 additions and 29 deletions

View file

@ -16,7 +16,7 @@
.. automethod:: make_batch .. automethod:: make_batch
.. automethod:: make_initial_rows .. automethod:: populate
.. automethod:: refresh .. automethod:: refresh
@ -24,7 +24,7 @@
.. automethod:: refreshable .. automethod:: refreshable
.. automethod:: requires_prefill .. automethod:: should_populate
.. automethod:: setup_populate .. automethod:: setup_populate

View file

@ -70,7 +70,7 @@ class MakeBatch(Action):
kwargs['created_by'] = session.query(model.User).filter_by(username=user).one() kwargs['created_by'] = session.query(model.User).filter_by(username=user).one()
batch = handler.make_batch(session, **kwargs) batch = handler.make_batch(session, **kwargs)
handler.set_input_file(batch, path) handler.set_input_file(batch, path)
handler.make_initial_rows(batch) handler.populate(batch)
if parse_bool(delete_if_empty): if parse_bool(delete_if_empty):
session.flush() session.flush()

View file

@ -44,11 +44,11 @@ class HandheldBatchHandler(BatchHandler):
""" """
batch_model_class = model.HandheldBatch batch_model_class = model.HandheldBatch
def requires_prefill(self, batch): def should_populate(self, batch):
# all handheld batches must come from input data file # all handheld batches must come from input data file
return True return True
def make_initial_rows(self, batch, progress=None): def populate(self, batch, progress=None):
""" """
Pre-fill batch with row data from an input data file, parsed according Pre-fill batch with row data from an input data file, parsed according
to the batch device type. to the batch device type.
@ -168,7 +168,7 @@ class HandheldBatchHandler(BatchHandler):
default='rattail.batch.inventory:InventoryBatchHandler') default='rattail.batch.inventory:InventoryBatchHandler')
session = orm.object_session(handheld_batch) session = orm.object_session(handheld_batch)
batch = handler.make_batch(session, created_by=user, handheld_batch=handheld_batch) batch = handler.make_batch(session, created_by=user, handheld_batch=handheld_batch)
handler.make_initial_rows(batch, progress=progress) handler.populate(batch, progress=progress)
return batch return batch
def make_label_batch(self, handheld_batch, user, progress=None): def make_label_batch(self, handheld_batch, user, progress=None):
@ -176,5 +176,5 @@ class HandheldBatchHandler(BatchHandler):
default='rattail.batch.labels:LabelBatchHandler') default='rattail.batch.labels:LabelBatchHandler')
session = orm.object_session(handheld_batch) session = orm.object_session(handheld_batch)
batch = handler.make_batch(session, created_by=user, handheld_batch=handheld_batch) batch = handler.make_batch(session, created_by=user, handheld_batch=handheld_batch)
handler.make_initial_rows(batch, progress=progress) handler.populate(batch, progress=progress)
return batch return batch

View file

@ -162,12 +162,6 @@ class BatchHandler(object):
""" """
return self.populate_batches return self.populate_batches
def requires_prefill(self, batch):
warnings.warn("Calling `BatchHandler.requires_prefill()` is deprecated. "
"Please update your code to use `should_populate()` instead.",
DeprecationWarning)
return self.should_populate(batch)
def setup_populate(self, batch, progress=None): def setup_populate(self, batch, progress=None):
""" """
Perform any setup (caching etc.) necessary for populating a batch. Perform any setup (caching etc.) necessary for populating a batch.
@ -186,12 +180,6 @@ class BatchHandler(object):
""" """
raise NotImplementedError("Please implement `{}.populate()` method".format(batch.__class__.__name__)) raise NotImplementedError("Please implement `{}.populate()` method".format(batch.__class__.__name__))
def make_initial_rows(self, batch, progress=None):
warnings.warn("Calling `BatchHandler.make_initial_rows()` is deprecated. "
"Please update your code to use `populate()` instead.",
DeprecationWarning)
return self.populate(batch, progress=progress)
def refreshable(self, batch): def refreshable(self, batch):
""" """
This method should return a boolean indicating whether or not the This method should return a boolean indicating whether or not the

View file

@ -39,11 +39,11 @@ class InventoryBatchHandler(BatchHandler):
""" """
batch_model_class = model.InventoryBatch batch_model_class = model.InventoryBatch
def requires_prefill(self, batch): def should_populate(self, batch):
# all inventory batches must (currently) come from handheld batch # all inventory batches must (currently) come from handheld batch
return True return True
def make_initial_rows(self, batch, progress=None): def populate(self, batch, progress=None):
""" """
Pre-fill batch with row data from an input data file, parsed according Pre-fill batch with row data from an input data file, parsed according
to the batch device type. to the batch device type.

View file

@ -66,7 +66,7 @@ class LabelBatchHandler(BatchHandler):
self.calc_check_digit = parse_bool(self.calc_check_digit) self.calc_check_digit = parse_bool(self.calc_check_digit)
return super(LabelBatchHandler, self).make_batch(session, progress, **kwargs) return super(LabelBatchHandler, self).make_batch(session, progress, **kwargs)
def make_initial_rows(self, batch, progress=None): def populate(self, batch, progress=None):
""" """
Pre-fill batch with row data from handheld batch, etc. Pre-fill batch with row data from handheld batch, etc.
""" """

View file

@ -38,7 +38,7 @@ class PricingBatchHandler(BatchHandler):
""" """
batch_model_class = model.PricingBatch batch_model_class = model.PricingBatch
def make_initial_rows(self, batch, progress=None): def populate(self, batch, progress=None):
""" """
Batch row data comes from product query. Batch row data comes from product query.
""" """

View file

@ -42,12 +42,12 @@ class PurchaseBatchHandler(BatchHandler):
# set this to True for handler to skip various "case" logic # set this to True for handler to skip various "case" logic
ignore_cases = False ignore_cases = False
def requires_prefill(self, batch): def should_populate(self, batch):
# TODO: this probably should change soon, for now this works.. # TODO: this probably should change soon, for now this works..
return batch.purchase and batch.mode in (self.enum.PURCHASE_BATCH_MODE_RECEIVING, return batch.purchase and batch.mode in (self.enum.PURCHASE_BATCH_MODE_RECEIVING,
self.enum.PURCHASE_BATCH_MODE_COSTING) self.enum.PURCHASE_BATCH_MODE_COSTING)
def make_initial_rows(self, batch, progress=None): def populate(self, batch, progress=None):
assert batch.purchase and batch.mode in (self.enum.PURCHASE_BATCH_MODE_RECEIVING, assert batch.purchase and batch.mode in (self.enum.PURCHASE_BATCH_MODE_RECEIVING,
self.enum.PURCHASE_BATCH_MODE_COSTING) self.enum.PURCHASE_BATCH_MODE_COSTING)

View file

@ -39,7 +39,7 @@ class VendorCatalogHandler(BatchHandler):
""" """
batch_model_class = model.VendorCatalog batch_model_class = model.VendorCatalog
def requires_prefill(self, batch): def should_populate(self, batch):
# all vendor catalogs must come from data file # all vendor catalogs must come from data file
return True return True
@ -65,7 +65,7 @@ class VendorCatalogHandler(BatchHandler):
setup_populate = setup setup_populate = setup
setup_refresh = setup setup_refresh = setup
def make_initial_rows(self, batch, progress=None): def populate(self, batch, progress=None):
""" """
Pre-fill batch with row data from an input data file, leveraging a Pre-fill batch with row data from an input data file, leveraging a
specific catalog parser. specific catalog parser.

View file

@ -49,7 +49,7 @@ class VendorInvoiceHandler(BatchHandler):
kwargs['vendor'] = api.get_vendor(session, parser.vendor_key) kwargs['vendor'] = api.get_vendor(session, parser.vendor_key)
return super(VendorInvoiceHandler, self).make_batch(session, progress=progress, **kwargs) return super(VendorInvoiceHandler, self).make_batch(session, progress=progress, **kwargs)
def requires_prefill(self, batch): def should_populate(self, batch):
# all vendor invoices must come from data file # all vendor invoices must come from data file
return True return True
@ -59,7 +59,7 @@ class VendorInvoiceHandler(BatchHandler):
def setup_refresh(self, batch, progress=None): def setup_refresh(self, batch, progress=None):
self.vendor = batch.vendor self.vendor = batch.vendor
def make_initial_rows(self, batch, progress=None): def populate(self, batch, progress=None):
""" """
Pre-fill batch with row data from an input data file, leveraging a Pre-fill batch with row data from an input data file, leveraging a
specific invoice parser. specific invoice parser.