mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
Removed Cart table, its dependency on spree orders table and removed some more dead code related to this
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -10,7 +10,6 @@ end
|
||||
Spree::Order.class_eval do
|
||||
belongs_to :order_cycle
|
||||
belongs_to :distributor, class_name: 'Enterprise'
|
||||
belongs_to :cart
|
||||
belongs_to :customer
|
||||
has_one :proxy_order
|
||||
has_one :subscription, through: :proxy_order
|
||||
|
||||
@@ -9,7 +9,6 @@ Spree.user_class.class_eval do
|
||||
has_many :owned_groups, class_name: 'EnterpriseGroup', foreign_key: :owner_id, inverse_of: :owner
|
||||
has_many :account_invoices
|
||||
has_many :billable_periods, foreign_key: :owner_id, inverse_of: :owner
|
||||
has_one :cart
|
||||
has_many :customers
|
||||
has_many :credit_cards
|
||||
|
||||
|
||||
7
db/migrate/20180812214434_drop_carts.rb
Normal file
7
db/migrate/20180812214434_drop_carts.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class DropCarts < ActiveRecord::Migration
|
||||
def change
|
||||
remove_foreign_key :spree_orders, column: :cart_id
|
||||
remove_column :spree_orders, :cart_id
|
||||
drop_table :carts
|
||||
end
|
||||
end
|
||||
12
db/schema.rb
12
db/schema.rb
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20180510083800) do
|
||||
ActiveRecord::Schema.define(:version => 20180812214434) do
|
||||
|
||||
create_table "account_invoices", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
@@ -53,12 +53,6 @@ ActiveRecord::Schema.define(:version => 20180510083800) do
|
||||
|
||||
add_index "billable_periods", ["account_invoice_id"], :name => "index_billable_periods_on_account_invoice_id"
|
||||
|
||||
create_table "carts", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
add_index "carts", ["user_id"], :name => "index_carts_on_user_id"
|
||||
|
||||
create_table "column_preferences", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
t.string "action_name", :null => false
|
||||
@@ -621,7 +615,6 @@ ActiveRecord::Schema.define(:version => 20180510083800) do
|
||||
t.integer "order_cycle_id"
|
||||
t.string "currency"
|
||||
t.string "last_ip_address"
|
||||
t.integer "cart_id"
|
||||
t.integer "customer_id"
|
||||
end
|
||||
|
||||
@@ -1203,8 +1196,6 @@ ActiveRecord::Schema.define(:version => 20180510083800) do
|
||||
add_foreign_key "billable_periods", "enterprises", name: "bill_items_enterprise_id_fk"
|
||||
add_foreign_key "billable_periods", "spree_users", name: "bill_items_owner_id_fk", column: "owner_id"
|
||||
|
||||
add_foreign_key "carts", "spree_users", name: "carts_user_id_fk", column: "user_id"
|
||||
|
||||
add_foreign_key "coordinator_fees", "enterprise_fees", name: "coordinator_fees_enterprise_fee_id_fk"
|
||||
add_foreign_key "coordinator_fees", "order_cycles", name: "coordinator_fees_order_cycle_id_fk"
|
||||
|
||||
@@ -1285,7 +1276,6 @@ ActiveRecord::Schema.define(:version => 20180510083800) do
|
||||
add_foreign_key "spree_option_values_variants", "spree_option_values", name: "spree_option_values_variants_option_value_id_fk", column: "option_value_id"
|
||||
add_foreign_key "spree_option_values_variants", "spree_variants", name: "spree_option_values_variants_variant_id_fk", column: "variant_id"
|
||||
|
||||
add_foreign_key "spree_orders", "carts", name: "spree_orders_cart_id_fk"
|
||||
add_foreign_key "spree_orders", "customers", name: "spree_orders_customer_id_fk"
|
||||
add_foreign_key "spree_orders", "enterprises", name: "spree_orders_distributor_id_fk", column: "distributor_id"
|
||||
add_foreign_key "spree_orders", "order_cycles", name: "spree_orders_order_cycle_id_fk"
|
||||
|
||||
Reference in New Issue
Block a user