Conceptual architectural change for CLI user app

This commit is contained in:
2015-09-07 19:10:54 +02:00
parent 4ef7ecba41
commit 1caa488524
15 changed files with 163 additions and 140 deletions
@@ -11,31 +11,5 @@ module Users
render json: JSONAPI::Serializer.serialize(orders, serializer: Users::OrderSerializer, include: %w[list product_orders product_orders.order], is_collection: true)
end
# Used by the user Ember app
# POST /user/orders
def create
# render json: {}, status: :unprocessable_entity and return unless params[:order].present? && params[:order][:product_orders].present?
if list = current_user.active_list
render json: {}, status: :not_acceptable and return unless list.supplier.open?
else
#TODO: More logic about creating a new list!!!!!, usercontroller table_info should become irrelevant
#NOTE: security bug here!!!!!!
# - supplier.open?
# - etc....
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?
#render json: json_alert('messages.table_is_occupied', location: :join_occupied_table, location_params: {table_id: @table.id})
render json: {}, status: :not_acceptable and return
end
list = List.from_table( table, current_user )
end
order = list.place_order product_orders: params[:product_orders], user: current_user
render json: order, serializer: Users::OrderSerializer
#render nothing: true
end
end
end