JSONApi part1

This commit is contained in:
2015-09-02 15:52:48 +02:00
parent 5d1ecd81c8
commit f47a8a9ed0
51 changed files with 386 additions and 141 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
class JoinRequestSerializer < Qwaiter::Serializer
attributes :list_id
has_one :user, serializer: UserUserSerializer
has_one :user, serializer: Users::UserSerializer
end
+1 -1
View File
@@ -1,4 +1,4 @@
# Used for user ember1
class ProductOrderSerializer < Qwaiter::Serializer
attributes :order_id, :product_id, :quantity, :price, :product_name, :product_variant
attributes :quantity, :price, :product_name, :product_variant
end
@@ -21,9 +21,9 @@ class UserExtendedListSerializer < Qwaiter::Serializer
end
has_many :orders
#has_many :product_categories
has_one :table, serializer: UserExtendedTableSerializer # this one add a lot of stuff
has_one :table, serializer: Users::TableSerializer # this one add a lot of stuff
has_many :join_requests, serializer: JoinRequestSerializer
has_many :users, serializer: UserUserSerializer
has_many :users, serializer: Users::UserSerializer
#has_one :supplier # added by other resource
def extended_version
-20
View File
@@ -1,20 +0,0 @@
class UserListSerializer < Qwaiter::Serializer
# user ids for facebook pictures
attributes :state, :needs_help, :needs_payment, :user_requests_closing,
:is_paid, :price, :table_id, :table_number, :section_id, :user_ids,
:cached_supplier_name, :closed_at, :supplier_id, :extended_version
#def has_active_orders
#object.has_active_orders?
#end
def cached_supplier_name
object.supplier.name
end
def extended_version
false
end
# has_many :users, serializer: UserUserSerializer
# has_many :orders
# has_one :supplier, serializer: UserSupplierSerializer
end
-4
View File
@@ -1,4 +0,0 @@
class UserTableSerializer < Qwaiter::Serializer
self.root = :table
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied, :needs_help
end
+11
View File
@@ -0,0 +1,11 @@
class Users::ListSerializer < Qwaiter::Serializer
# user ids for facebook pictures
self.root = :list
attributes :state, :needs_help, :needs_payment, :user_requests_closing,
:is_paid, :price, :closed_at
has_many :users, serializer: Users::UserSerializer
has_many :orders, url: ->(list){ "/user/lists/#{list.id}/orders" }, serializer: OrderSerializer
has_one :supplier, serializer: Users::SupplierSerializer
#belongs_to :table
end
@@ -0,0 +1,8 @@
class Users::OrderSerializer < Qwaiter::Serializer
attributes :state #, :list_id, :section_id, :table_id #, :price
has_many :product_orders, serializer: Users::ProductOrderSerializer
belongs_to :list
#belongs_to :section
#belongs_to :table
end
@@ -0,0 +1,6 @@
# Used for user ember1
class Users::ProductOrderSerializer < Qwaiter::Serializer
attributes :quantity, :price, :product_name, :product_variant
# belongs_to :product #DO NOT USE THIS, THIS IS NOT NEEDED
belongs_to :order
end
@@ -1,4 +1,4 @@
class UserSupplierSerializer < Qwaiter::Serializer
class Users::SupplierSerializer < Qwaiter::Serializer
self.root = :supplier
attributes :extended_version, :open, :name
+12
View File
@@ -0,0 +1,12 @@
class Users::TableSerializer < Qwaiter::Serializer
self.root = :table
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied, :supplier_id #, :alist_id
#def list_id
#object.active_list_id || object.active_list.try(:id)
#end
#def list
#object.active_list
#end
end
@@ -1,4 +1,4 @@
class UserUserSerializer < Qwaiter::Serializer
class Users::UserSerializer < Qwaiter::Serializer
self.root = :user
attributes :email, :provider, :uid, :name, :avatar