mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
- Copied translations for payment_states, shipment_states and order_states into locale en.yml. - Enabled global Javascript function `translate` to deal with scopes like 'spree.shipment_states'. - Removed `humanize` call from order serializer and added translation scopes to accounts page. - Test OrderSerializer for untranslated attributes - Require spec helper in serializer specs
32 lines
776 B
Ruby
32 lines
776 B
Ruby
module Api
|
|
class OrderSerializer < ActiveModel::Serializer
|
|
attributes :number, :completed_at, :total, :state, :shipment_state, :payment_state, :outstanding_balance, :payments, :path
|
|
|
|
has_many :payments, serializer: Api::PaymentSerializer
|
|
|
|
def completed_at
|
|
object.completed_at.blank? ? "" : I18n.l(object.completed_at, format: :long)
|
|
end
|
|
|
|
def total
|
|
object.total.to_money.to_s
|
|
end
|
|
|
|
def shipment_state
|
|
object.shipment_state ? object.shipment_state : nil
|
|
end
|
|
|
|
def payment_state
|
|
object.payment_state ? object.payment_state : nil
|
|
end
|
|
|
|
def state
|
|
object.state ? object.state : nil
|
|
end
|
|
|
|
def path
|
|
Spree::Core::Engine.routes_url_helpers.order_url(object.number, only_path: true)
|
|
end
|
|
end
|
|
end
|