Merge pull request #2539 from luisramos0/delete_dead_cart

removed Cart route, controller, model and specs: dead code
This commit is contained in:
Maikel
2018-08-22 17:35:58 +10:00
committed by GitHub
15 changed files with 8 additions and 340 deletions

View File

@@ -1,39 +0,0 @@
module OpenFoodNetwork
class CartController < ApplicationController
respond_to :json
# before_filter :authorize_read!, :except => [:index, :search, :create]
def new
@cart = Cart.new(current_api_user)
if @cart.save
respond_with(@cart, :status => 201)
else
invalid_resource!(@cart)
end
end
def show
@cart = Cart.find(params[:id])
respond_with(@cart)
end
def add_variant
@cart = Cart.find(params[:cart_id])
distributor = Enterprise.find_by_permalink(params[:distributor_id])
order_cycle = OrderCycle.find(params[:order_cycle_id]) if params[:order_cycle_id]
if @cart.add_variant params[:variant_id], params[:quantity], distributor, order_cycle, current_currency
respond_with(@cart)
else
respond_with(@cart.populate_errors)
end
end
private
def current_currency
Spree::Config[:currency]
end
end
end

View File

@@ -202,20 +202,6 @@ Spree::OrdersController.class_eval do
end
end
def populate_cart hash
if spree_current_user
unless spree_current_user.cart
spree_current_user.build_cart
cart = Cart.create(user: spree_current_user)
spree_current_user.cart = cart
spree_current_user.save
end
distributor = Enterprise.find(hash[:distributor_id])
order_cycle = OrderCycle.find(hash[:order_cycle_id]) if hash[:order_cycle_id]
spree_current_user.cart.add_variant hash[:variants].keys.first, hash[:variants].values.first, distributor, order_cycle, current_currency
end
end
# Rails to_json encodes Float::INFINITY as Infinity, which is not valid JSON
# Return it as a large integer (max 32 bit signed int)
def wrap_json_infinity(n)