Save progress
This commit is contained in:
@@ -134,7 +134,7 @@ class UserController < Users::ApplicationController
|
||||
if @list = @table.active_list
|
||||
if @list.user_ids.include?(current_user.id)
|
||||
render json: {approved: true}
|
||||
elsif @list.join_requests.include?(current_user.id)
|
||||
elsif @list.join_request_user_ids.include?(current_user.id)
|
||||
render json: {waiting: true}
|
||||
else
|
||||
render json: {rejected: true}
|
||||
|
||||
@@ -11,6 +11,7 @@ module Users
|
||||
#EMBER
|
||||
def current
|
||||
list = current_user.active_list
|
||||
render json: {}, status: :not_found and return unless list.present?
|
||||
[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, serializer: UserExtendedListSerializer
|
||||
|
||||
@@ -2,8 +2,18 @@ module Users
|
||||
class OrdersController < Users::ApplicationController
|
||||
respond_to :json
|
||||
def create
|
||||
|
||||
converted_order = params[:order][:product_orders].each_with_object({}){|po, o| o[po[:product_id]] = po[:quantity] }
|
||||
list = current_user.active_list
|
||||
unless list = current_user.active_list
|
||||
table = Table.find(params[:order][:table_id])
|
||||
|
||||
if table.occupied?
|
||||
#render json: json_alert('messages.table_is_occupied', location: :join_occupied_table, location_params: {table_id: @table.id})
|
||||
render status: :not_acceptable and return
|
||||
end
|
||||
|
||||
list = List.from_table( table, current_user )
|
||||
end
|
||||
order = list.place_order converted_order
|
||||
render json: order, serializer: OrderSerializer
|
||||
end
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
module Users
|
||||
class TablesController < Users::ApplicationController
|
||||
def show
|
||||
@table = Table.find(params[:id])
|
||||
render json: @table, serializer: UserExtendedTableSerializer
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user