Add products API route to fetch label profiles for use w/ printing

This commit is contained in:
Lance Edgar 2023-09-02 10:56:06 -05:00
parent de373a683b
commit 75caface6b
2 changed files with 29 additions and 7 deletions

View file

@ -658,16 +658,13 @@ class ProductView(MasterView):
return pretty_quantity(inventory.on_order)
def template_kwargs_index(self, **kwargs):
kwargs = super(ProductView, self).template_kwargs_index(**kwargs)
kwargs = super().template_kwargs_index(**kwargs)
app = self.get_rattail_app()
label_handler = app.get_label_handler()
model = self.model
if self.expose_label_printing:
kwargs['label_profiles'] = self.Session.query(model.LabelProfile)\
.filter(model.LabelProfile.visible == True)\
.order_by(model.LabelProfile.ordinal)\
.all()
kwargs['label_profiles'] = label_handler.get_label_profiles(self.Session())
kwargs['quick_label_speedbump_threshold'] = self.rattail_config.getint(
'tailbone', 'products.quick_labels.speedbump_threshold')