Add support for pricing batches

This commit is contained in:
Lance Edgar 2016-11-21 19:36:57 -06:00
parent fdd0b6ec3b
commit 668191b2e9
5 changed files with 152 additions and 6 deletions

View file

@ -336,6 +336,12 @@ class ProductsView(MasterView):
'instance_title': self.get_instance_title(instance),
'form': form})
def get_supported_batches(self):
return {
'labels': 'rattail.batch.labels:LabelBatchHandler',
'pricing': 'rattail.batch.pricing:PricingBatchHandler',
}
def make_batch(self):
"""
View for making a new batch from current product grid query.
@ -348,10 +354,7 @@ class ProductsView(MasterView):
return self.make_batch_legacy(providers)
# okay then, new-style it is
# TODO: make this more configurable surely..?
supported = {
'labels': 'rattail.batch.labels:LabelBatchHandler',
}
supported = self.get_supported_batches()
if self.request.method == 'POST':
batch_key = self.request.POST.get('batch_type')
@ -394,10 +397,16 @@ class ProductsView(MasterView):
progress.session.load()
progress.session['complete'] = True
progress.session['success_url'] = self.request.route_url('labels.batch.view', uuid=batch.uuid)
progress.session['success_url'] = self.get_batch_view_url(batch)
progress.session['success_msg'] = 'Batch has been created: {}'.format(batch)
progress.session.save()
def get_batch_view_url(self, batch):
if batch.batch_key == 'labels':
return self.request.route_url('labels.batch.view', uuid=batch.uuid)
if batch.batch_key == 'pricing':
return self.request.route_url('batch.pricing.view', uuid=batch.uuid)
def make_batch_legacy(self, providers):
if self.request.method == 'POST':
provider_key = self.request.POST.get('provider')