User app updates

This commit is contained in:
2014-03-27 21:51:16 +01:00
parent 6af7dc74af
commit e179f6e582
37 changed files with 362 additions and 53 deletions
+14 -10
View File
@@ -1,14 +1,18 @@
class OrderSerializer < Qwaiter::Serializer
embed :ids
attributes :state, :list_id, :section_id, :product_orders, :price
embed :ids, include: true
attributes :state, :list_id, :section_id #, :price
def product_orders
@product_orders ||= object.product_orders.include_relation(:product) .map do |product_order|
{product_name: product_order.product.name, id: product_order.id, quantity: product_order.quantity, price: product_order.price}
end
end
# todo, put this logic in Ember
#def product_orders
#@product_orders ||= object.product_orders.include_relation(:product) .map do |product_order|
#{product_name: product_order.product.name, id: product_order.id, quantity: product_order.quantity, price: product_order.price}
#end
#end
def price
product_orders.inject(0){|sum, po| sum + po[:quantity] * po[:price]}.round(2)
end
# todo, put this logic in Ember
#def price
#product_orders.inject(0){|sum, po| sum + po[:quantity] * po[:price]}.round(2)
#end
has_many :product_orders
end