Continue adding product variants

This commit is contained in:
2015-04-13 17:57:06 +02:00
parent 6746eaa383
commit 2b036368cf
32 changed files with 169 additions and 12224 deletions
+4 -7
View File
@@ -6,9 +6,6 @@ module Users
# POST /user/orders
def create
# render json: {}, status: :unprocessable_entity and return unless params[:order].present? && params[:order][:product_orders].present?
# converted_order = params[:order][:product_orders].each_with_object({}){|po, o| o[po[:product_id]] = po[:quantity] }
converted_order = params[:order]
table_id = params[:order].delete('table_id')
if list = current_user.active_list
render json: {}, status: :not_acceptable and return unless list.supplier.open?
else
@@ -16,8 +13,8 @@ module Users
#NOTE: security bug here!!!!!!
# - supplier.open?
# - etc....
render json: {}, status: :unprocessable_entity and return unless table_id.present?
table = Table.find(table_id)
render json: {}, status: :unprocessable_entity and return unless params[:table_id].present?
table = Table.find(params[:table_id])
render json: {}, status: :not_acceptable and return unless table.supplier.open?
if table.occupied?
@@ -27,8 +24,8 @@ module Users
list = List.from_table( table, current_user )
end
order = list.place_order products: converted_order, user: current_user
render json: order, serializer: OrderSerializer
order = list.place_order product_orders: params[:product_orders], user: current_user
render json: order, serializer: OrderSerializer
#render nothing: true
end
end