Files
mozo-backend/app/serializers/user_extended_list_serializer.rb
T

29 lines
1.2 KiB
Ruby

#class ListExtendedSerializer
#render json: {
#list: list.serialized_with_status_join_requests_and_supplier_counters.merge(order_ids: list.orders.map(&:id)),
#}
#.merge(ActiveModel::ArraySerializer.new(list.supplier.product_categories, each_serializer: ProductCategorySerializer, root: :product_categories).as_json)
#.merge(ActiveModel::ArraySerializer.new(list.orders, each_serializer: OrderSerializer, root: :orders).as_json)
#end
class UserExtendedListSerializer < Qwaiter::Serializer
# user ids for facebook pictures
self.root = :list
attributes :extended_version, :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price,
:table_id, :table_number, :section_id, :user_ids, :supplier_id, :closed_at
#:supplier_orders_in_process_count, :supplier_orders_placed_count
def has_active_orders
object.has_active_orders?
end
has_many :orders
#has_many :product_categories
has_one :table, serializer: UserExtendedTableSerializer # this one add a lot of stuff
has_many :join_requests, serializer: JoinRequestSerializer
has_many :users, serializer: UserUserSerializer
#has_one :supplier # added by other resource
def extended_version
true
end
end