mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Remove distributor association from orders and from the checkout process
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
module Spree
|
||||
class Distributor < ActiveRecord::Base
|
||||
self.table_name = 'distributors'
|
||||
has_many :orders
|
||||
belongs_to :country
|
||||
belongs_to :state
|
||||
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
Spree::Order.class_eval do
|
||||
attr_accessible :distributor_id
|
||||
|
||||
belongs_to :distributor
|
||||
|
||||
before_validation :shipping_address_from_distributor
|
||||
# before_validation :shipping_address_from_distributor
|
||||
|
||||
private
|
||||
def shipping_address_from_distributor
|
||||
if distributor
|
||||
ship_address.firstname = bill_address.firstname
|
||||
ship_address.lastname = bill_address.lastname
|
||||
ship_address.phone = bill_address.phone
|
||||
# def shipping_address_from_distributor
|
||||
# if distributor
|
||||
# ship_address.firstname = bill_address.firstname
|
||||
# ship_address.lastname = bill_address.lastname
|
||||
# ship_address.phone = bill_address.phone
|
||||
|
||||
ship_address.address1 = distributor.pickup_address
|
||||
ship_address.city = distributor.city
|
||||
ship_address.zipcode = distributor.post_code
|
||||
ship_address.state = distributor.state
|
||||
ship_address.country_id = distributor.country_id
|
||||
end
|
||||
end
|
||||
# ship_address.address1 = distributor.pickup_address
|
||||
# ship_address.city = distributor.city
|
||||
# ship_address.zipcode = distributor.post_code
|
||||
# ship_address.state = distributor.state
|
||||
# ship_address.country_id = distributor.country_id
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class MoveDistributorFromOrderToProduct < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :spree_orders, :distributor_id
|
||||
add_column :spree_products, :distributor_id, :integer
|
||||
Spree::Order.reset_column_information
|
||||
Spree::Product.reset_column_information
|
||||
|
||||
# Associate all products with the first distributor so they'll be valid
|
||||
distributor = Spree::Distributor.first
|
||||
Spree::Product.update_all("distributor_id = #{distributor.id}") if distributor
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120520062061) do
|
||||
ActiveRecord::Schema.define(:version => 20120618061537) do
|
||||
|
||||
create_table "distributors", :force => true do |t|
|
||||
t.string "name"
|
||||
@@ -248,7 +248,6 @@ ActiveRecord::Schema.define(:version => 20120520062061) do
|
||||
t.string "payment_state"
|
||||
t.string "email"
|
||||
t.text "special_instructions"
|
||||
t.integer "distributor_id"
|
||||
end
|
||||
|
||||
add_index "spree_orders", ["number"], :name => "index_orders_on_number"
|
||||
@@ -354,6 +353,7 @@ ActiveRecord::Schema.define(:version => 20120520062061) do
|
||||
t.datetime "updated_at"
|
||||
t.integer "count_on_hand", :default => 0, :null => false
|
||||
t.integer "supplier_id"
|
||||
t.integer "distributor_id"
|
||||
end
|
||||
|
||||
add_index "spree_products", ["available_on"], :name => "index_products_on_available_on"
|
||||
|
||||
@@ -23,7 +23,7 @@ feature %q{
|
||||
end
|
||||
|
||||
context "Given I am buying a product", :js => true do
|
||||
scenario "I should be able choose a distributor to pick up from" do
|
||||
scenario "I should be able choose a distributor to pick up from", :skip => true do
|
||||
login_to_consumer_section
|
||||
|
||||
click_link 'Fuji apples'
|
||||
|
||||
@@ -37,6 +37,10 @@ RSpec.configure do |config|
|
||||
# rspec-rails.
|
||||
config.infer_base_class_for_anonymous_controllers = false
|
||||
|
||||
# ## Filters
|
||||
#
|
||||
config.filter_run_excluding :skip => true
|
||||
|
||||
config.before(:suite) do
|
||||
DatabaseCleaner.strategy = :truncation, { :except => ['spree_countries', 'spree_states'] }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user