End of evening commit, changing supplier to JSONAPI
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
class Suppliers::EmployeeSerializer < Qwaiter::Serializer
|
||||
class Suppliers::EmployeeSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :name, :email, :manager, :active, :color
|
||||
end
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
class Suppliers::EmployeeShiftSerializer < Qwaiter::Serializer
|
||||
self.root = :employee_shift
|
||||
#embed :ids, include: true
|
||||
class Suppliers::EmployeeShiftSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :start_from, :end_on, :employee_id, :supplier_id
|
||||
#has_one :supplier
|
||||
has_one :supplier, serializer: Suppliers::SupplierSerializer
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class Suppliers::ExtendedSectionSerializer < Qwaiter::Serializer
|
||||
root 'section'
|
||||
attributes :title, :path, :width, :height
|
||||
has_many :tables, serializer: Suppliers::ExtendedTableSerializer
|
||||
end
|
||||
#class Suppliers::ExtendedSectionSerializer < Qwaiter::Serializer
|
||||
# attributes :title, :path, :width, :height
|
||||
# has_many :tables, serializer: Suppliers::TableSerializer
|
||||
#end
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
class Suppliers::ExtendedTableSerializer < Qwaiter::Serializer
|
||||
root :table
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id#, :active_list_id
|
||||
|
||||
#def list_id
|
||||
#object.active_list_id || object.active_list.try(:id)
|
||||
#end
|
||||
|
||||
#def list
|
||||
#object.active_list
|
||||
#end
|
||||
|
||||
#has_one :list, key: :active_list_id, serializer: SupplierExtendedListSerializer
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class Suppliers::JoinRequestSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
has_one :user, serializer: Suppliers::SupplierSerializer
|
||||
has_one :list, serializer: Suppliers::ListSerializer
|
||||
end
|
||||
@@ -1,18 +1,9 @@
|
||||
class Suppliers::ListSerializer < 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
|
||||
has_many :orders
|
||||
#has_many :product_categories
|
||||
#has_one :table, serializer: SupplierTableSerializer # tables are part of the sectoins load
|
||||
has_many :join_requests
|
||||
has_many :users, serializer: Suppliers::UserSerializer
|
||||
class Suppliers::ListSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, :closed_at
|
||||
|
||||
#def has_active_orders
|
||||
#object.has_active_orders?
|
||||
#end
|
||||
def extended_version
|
||||
true
|
||||
end
|
||||
has_many :orders, serializer: Suppliers::OrderSerializer
|
||||
has_many :join_requests, serializer: Suppliers::JoinRequestSerializer
|
||||
has_many :users, serializer: Suppliers::UserSerializer
|
||||
has_one :table, serializer: Suppliers::TableSerializer
|
||||
end
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class Suppliers::OrderSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :state #, :list_id, :section_id, :table_id #, :price
|
||||
|
||||
has_one :list, serializer: Suppliers::ListSerializer
|
||||
has_many :product_orders, serializer: Suppliers::ProductOrderSerializer
|
||||
|
||||
end
|
||||
@@ -1,11 +1,6 @@
|
||||
class Suppliers::PageSerializer < Qwaiter::Serializer
|
||||
self.root = :page
|
||||
attributes :name, :title, :body, :locale, :position
|
||||
def name
|
||||
object.name.to_s.sub /^suppliers-/, ''
|
||||
end
|
||||
|
||||
def id
|
||||
name
|
||||
end
|
||||
class Suppliers::PageSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :title, :body, :locale, :position
|
||||
attribute(:name) { object.name.to_s.sub /^suppliers-/, '' }
|
||||
attribute(:id) { object.name.to_s.sub /^suppliers-/, '' }
|
||||
end
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class Suppliers::ProductCategorySerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :name, :supplier_id, :active_on_sunday, :active_on_monday, :active_on_tuesday, :active_on_wednesday,
|
||||
:active_on_thursday, :active_on_friday, :active_on_saturday, :full_day, :start_from, :end_on,
|
||||
:position
|
||||
has_many :products, serializer: Suppliers::ProductSerializer
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class Suppliers::ProductOrderSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :quantity, :price, :product_name, :product_variant
|
||||
has_one :order, serializer: Suppliers::OrderSerializer
|
||||
has_one :product, serializer: Suppliers::ProductSerializer
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
class Suppliers::ProductSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :name, :price, :description, :code, :position, :visible, :active, :product_category_id
|
||||
attribute :image do
|
||||
if object.image.present?
|
||||
{small: object.image.url(:small)}
|
||||
else
|
||||
{small: object.image.url}
|
||||
end
|
||||
end
|
||||
|
||||
has_many :product_variants, serializer: Suppliers::ProductVariantSerializer
|
||||
end
|
||||
@@ -1,3 +1,5 @@
|
||||
class Suppliers::SectionAreaSerializer < Qwaiter::Serializer
|
||||
attributes :title, :width, :height, :position_x, :position_y, :section_id, :rounded
|
||||
class Suppliers::SectionAreaSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :title, :width, :height, :position_x, :position_y, :rounded
|
||||
has_one :section, serializer: Suppliers::SectionSerializer
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
class Suppliers::SectionElementSerializer < Qwaiter::Serializer
|
||||
attributes :name, :box_width, :box_height, :dpm, :svg, :position_x, :position_y, :rotation, :section_id
|
||||
attributes :name, :box_width, :box_height, :dpm, :svg, :position_x, :position_y, :rotation
|
||||
has_one :section, serializer: Suppliers::SectionSerializer
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Suppliers::SectionSerializer < Qwaiter::Serializer
|
||||
root :section
|
||||
class Suppliers::SectionSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :title, :path, :width, :height
|
||||
end
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
class Suppliers::SupplierSerializer < Qwaiter::Serializer
|
||||
self.root = :supplier
|
||||
attributes :extended_version, :open, :name, :email, :lat, :lng, :time_zone, :address, :house_number, :house_number_addition, :postal_code, :city, :country,
|
||||
class Suppliers::SupplierSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :open, :name, :email, :lat, :lng, :time_zone, :address, :house_number, :house_number_addition, :postal_code, :city, :country,
|
||||
:facebook_promotion_url, :iens_profile, :week_starts_on_monday, :orders_in_process_count, :orders_placed_count
|
||||
|
||||
def extended_version
|
||||
true
|
||||
end
|
||||
has_many :sections, serializer: Suppliers::ExtendedSectionSerializer
|
||||
has_many :product_categories
|
||||
has_many :sections, serializer: Suppliers::SectionSerializer
|
||||
has_many :product_categories, serializer: Suppliers::ProductCategorySerializer
|
||||
has_many :employees, serializer: Suppliers::EmployeeSerializer
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
class Suppliers::SvgElementSerializer < Qwaiter::Serializer
|
||||
class Suppliers::SvgElementSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :name, :box_width, :box_height, :dpm, :svg
|
||||
end
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class Suppliers::TableSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id#, :active_list_id
|
||||
end
|
||||
@@ -1,12 +1,5 @@
|
||||
class Suppliers::UserSerializer < Qwaiter::Serializer
|
||||
self.root = :user
|
||||
attributes :email, :provider, :uid, :name, :avatar, :list_id
|
||||
|
||||
def list_id
|
||||
object.active_list_id
|
||||
end
|
||||
|
||||
def name
|
||||
object.supplier_name
|
||||
end
|
||||
class Suppliers::UserSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :email, :provider, :uid, :avatar
|
||||
attribute(:name) { object.supplier_name }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user