serializer stuff

This commit is contained in:
2015-09-14 18:53:58 +02:00
parent 36e5b21b13
commit ef894f9e02
37 changed files with 141 additions and 63 deletions
@@ -7,12 +7,12 @@ module Suppliers
@employee_shifts.select! do |shift|
current_supplier.employee_ids.include?(shift.employee.try(:id))
end
render json: JSONAPI::Serializer.serialize(@employee_shifts, serializer: Suppliers::EmployeeShiftSerializer, is_collection: true, include: %w[employee supplier])
render json: JSONAPI::Serializer.serialize(@employee_shifts, serializer: Suppliers::EmployeeShiftSerializer, is_collection: true, include: %w[employee])
end
def create
@employee_shift.supplier = current_supplier
@employee_shift.save
render json: JSONAPI::Serializer.serialize(@employee_shift, serializer: Suppliers::EmployeeShiftSerializer, include: %w[employee supplier])
render json: JSONAPI::Serializer.serialize(@employee_shift, serializer: Suppliers::EmployeeShiftSerializer, include: %w[employee])
end
def update
@@ -31,6 +31,5 @@ module Suppliers
def employee_shift_params
params.require(:employee_shift).permit(:start_from, :end_on, :employee_id, :description)
end
end
end
@@ -23,13 +23,9 @@ module Suppliers
render json: JSONAPI::Serializer.serialize(@lists, serializer: Suppliers::ListSerializer, is_collection: true, include: %w[
orders
orders.list
orders.user
orders.product_orders
orders.product_orders.product
users
section
table
])
end
@@ -6,6 +6,15 @@ module Suppliers
def show
current_supplier.sections.include_relations(:tables, :section_areas, :section_elements, product_categories: {products: :product_variants})
#render json: JSONAPI::Serializer.serialize(current_supplier, serializer: Suppliers::SupplierSerializer, include: %w[
#sections
#sections.tables
#sections.section_areas
#sections.section_elements
#product_categories
#product_categories.products
#product_categories.products.product_variants
#]) #.new(current_supplier).as_json
render json: JSONAPI::Serializer.serialize(current_supplier, serializer: Suppliers::SupplierSerializer, include: %w[
sections
sections.tables
@@ -14,7 +23,7 @@ module Suppliers
product_categories
product_categories.products
product_categories.products.product_variants
]) #.new(current_supplier).as_json
])
end
def update
+1 -1
View File
@@ -27,7 +27,7 @@ module Users
def show
@list ||= List.find(params[:id]) if params[:id]
render json: {}, status: :not_found and return unless @list.present? && Array.wrap(@list.user_ids).include?(current_user.id)
render json: JSONAPI::Serializer.serialize(@list, serializer: Users::ListSerializer, include: %w[supplier users join_requests join_requests.list join_requests.user])
render json: JSONAPI::Serializer.serialize(@list, serializer: Users::ListSerializer, include: %w[supplier users join_requests join_requests.user])
end
# POST /user/list_needs_payment.json