Allow for null price when showing price history

This commit is contained in:
Lance Edgar 2021-12-10 16:33:53 -06:00
parent f549858c5d
commit a2032a7be2

View file

@ -1093,6 +1093,7 @@ class ProductView(MasterView):
""" """
AJAX view for fetching various types of price history for a product. AJAX view for fetching various types of price history for a product.
""" """
app = self.get_rattail_app()
product = self.get_instance() product = self.get_instance()
typ = self.request.params.get('type', 'regular') typ = self.request.params.get('type', 'regular')
@ -1106,8 +1107,9 @@ class ProductView(MasterView):
for history in data: for history in data:
history = dict(history) history = dict(history)
price = history['price'] price = history['price']
history['price'] = float(price) if price is not None:
history['price_display'] = "${:0.2f}".format(price) history['price'] = float(price)
history['price_display'] = app.render_currency(price)
changed = localtime(self.rattail_config, history['changed'], from_utc=True) changed = localtime(self.rattail_config, history['changed'], from_utc=True)
history['changed'] = six.text_type(changed) history['changed'] = six.text_type(changed)
history['changed_display_html'] = raw_datetime(self.rattail_config, changed) history['changed_display_html'] = raw_datetime(self.rattail_config, changed)