User app updates
This commit is contained in:
@@ -1,12 +1,25 @@
|
||||
module Users
|
||||
class ListsController < Users::ApplicationController
|
||||
|
||||
def index
|
||||
#lists = current_user.lists.include_relation(:supplier, :table)
|
||||
lists = List.for_user(current_user, page: params[:page], per_page: 2).include_relation(:supplier, :table)
|
||||
#lists.include_relation(:supplier)
|
||||
render json: lists, each_serializer: UserListSerializer, meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists
|
||||
end
|
||||
|
||||
#EMBER
|
||||
def current
|
||||
list = current_user.active_list
|
||||
[list].include_relation(supplier: {product_categories: :products}, orders: :product_orders) # table also when it is a real array :)
|
||||
render json: json_response(not_present: true) and return unless list.present?
|
||||
render json: {
|
||||
list: list.serialized_with_status_join_requests_and_supplier_counters,
|
||||
}.merge(ActiveModel::ArraySerializer.new(list.supplier.product_categories, each_serializer: ProductCategorySerializer, root: :product_categories).as_json)
|
||||
render json: list, serializer: UserExtendedListSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
list = List.find(params[:id])
|
||||
[list].include_relation(supplier: {product_categories: :products}, orders: :product_orders) # table also when it is a real array :)
|
||||
render json: list, serializer: UserExtendedListSerializer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user