mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Fix invalid JSON for on_demand products/variants with infinite on_hand
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
object @product
|
||||
attributes :id, :name, :price, :on_hand, :variant_unit, :variant_unit_scale, :variant_unit_name
|
||||
attributes :id, :name, :price, :variant_unit, :variant_unit_scale, :variant_unit_name, :on_demand
|
||||
|
||||
# Infinity is not a valid JSON object, but Rails encodes it anyway
|
||||
node( :on_hand ) { |p| p.on_hand.to_f.finite? ? p.on_hand : "On demand" }
|
||||
|
||||
node( :available_on ) { |p| p.available_on.blank? ? "" : p.available_on.strftime("%F %T") }
|
||||
node( :permalink_live ) { |p| p.permalink }
|
||||
@@ -9,4 +12,3 @@ end
|
||||
node( :variants ) do |p|
|
||||
partial 'spree/api/variants/bulk_index', :object => p.variants.order('id ASC')
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
object @variant
|
||||
|
||||
attributes :id, :options_text, :price, :unit_value, :unit_description, :on_hand
|
||||
attributes :id, :options_text, :price, :unit_value, :unit_description, :on_demand
|
||||
|
||||
# Infinity is not a valid JSON object, but Rails encodes it anyway
|
||||
node( :on_hand ) { |p| p.on_hand.to_f.finite? ? p.on_hand : "On demand" }
|
||||
|
||||
Reference in New Issue
Block a user