spree_core 2.2.6 → 2.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/spree/base_helper.rb +2 -1
- data/app/helpers/spree/products_helper.rb +7 -8
- data/app/models/spree/adjustment.rb +1 -1
- data/app/models/spree/asset.rb +1 -1
- data/app/models/spree/gateway/bogus.rb +3 -2
- data/app/models/spree/inventory_unit.rb +1 -1
- data/app/models/spree/item_adjustments.rb +1 -1
- data/app/models/spree/order.rb +9 -5
- data/app/models/spree/order_updater.rb +12 -27
- data/app/models/spree/payment.rb +7 -4
- data/app/models/spree/payment_method.rb +1 -1
- data/app/models/spree/payment_method/check.rb +2 -0
- data/app/models/spree/product.rb +2 -3
- data/app/models/spree/promotion.rb +1 -1
- data/app/models/spree/promotion/actions/create_line_items.rb +1 -0
- data/app/models/spree/promotion_handler/coupon.rb +5 -1
- data/app/models/spree/return_authorization.rb +2 -2
- data/app/models/spree/shipping_category.rb +2 -2
- data/app/models/spree/shipping_method_category.rb +1 -1
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_location.rb +1 -1
- data/app/models/spree/tax_category.rb +1 -1
- data/app/models/spree/tax_rate.rb +7 -4
- data/app/models/spree/variant.rb +1 -1
- data/app/models/spree/zone.rb +16 -17
- data/app/models/spree/zone_member.rb +1 -1
- data/config/locales/en.yml +3 -0
- data/db/migrate/20130611054351_rename_shipping_methods_zones_to_spree_shipping_methods_zones.rb +5 -0
- data/db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb +3 -5
- data/db/migrate/20141021194502_add_state_lock_version_to_order.rb +5 -0
- data/lib/generators/spree/install/install_generator.rb +3 -7
- data/lib/spree/core/controller_helpers/auth.rb +2 -2
- data/lib/spree/core/importer/order.rb +24 -9
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/permitted_attributes.rb +3 -1
- data/lib/spree/testing_support/factories/order_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +4 -4
- data/lib/spree/testing_support/factories/stock_factory.rb +2 -2
- data/lib/tasks/core.rake +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ced799e6508e709a118e4e7ce365c38c64d83e35
|
4
|
+
data.tar.gz: 649ea08eb8e94b74a418811cf004e0af6ed36185
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89a31fc0972175a5718c2960a99fc1c9f21fccccaf60b1de207c692dc5c58e457ceb640c36ca56276ccf42abec76de682d275df81fd4331ba62936b7663085f0
|
7
|
+
data.tar.gz: 3b6fbdbd8d8eebc5dbb21514cc2ae887743231bf97d4cc181ce089d7a387081d5b70271b2d0a2a6ffdb1bf00bbfedc5b2648571b12c59839b7fc326354d9b10d
|
@@ -162,9 +162,10 @@ module Spree
|
|
162
162
|
end
|
163
163
|
|
164
164
|
private
|
165
|
+
|
165
166
|
# Returns style of image or nil
|
166
167
|
def image_style_from_method_name(method_name)
|
167
|
-
if style = method_name.to_s.sub(/_image$/, '')
|
168
|
+
if method_name.to_s.match(/_image$/) && style = method_name.to_s.sub(/_image$/, '')
|
168
169
|
possible_styles = Spree::Image.attachment_definitions[:attachment][:styles]
|
169
170
|
style if style.in? possible_styles.with_indifferent_access
|
170
171
|
end
|
@@ -11,14 +11,13 @@ module Spree
|
|
11
11
|
|
12
12
|
# returns the formatted price for the specified variant as a difference from product price
|
13
13
|
def variant_price_diff(variant)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
14
|
+
variant_amount = variant.amount_in(current_currency)
|
15
|
+
product_amount = variant.product.amount_in(current_currency)
|
16
|
+
return if variant_amount == product_amount || product_amount.nil?
|
17
|
+
diff = variant.amount_in(current_currency) - product_amount
|
18
|
+
amount = Spree::Money.new(diff.abs, currency: current_currency).to_html
|
19
|
+
label = diff > 0 ? :add : :subtract
|
20
|
+
"(#{Spree.t(label)}: #{amount})".html_safe
|
22
21
|
end
|
23
22
|
|
24
23
|
# returns the formatted full price for the variant, if at least one variant price differs from product price
|
@@ -22,7 +22,7 @@
|
|
22
22
|
# it might be reinstated.
|
23
23
|
module Spree
|
24
24
|
class Adjustment < ActiveRecord::Base
|
25
|
-
belongs_to :adjustable, polymorphic: true
|
25
|
+
belongs_to :adjustable, polymorphic: true, touch: true
|
26
26
|
belongs_to :source, polymorphic: true
|
27
27
|
belongs_to :order, class_name: "Spree::Order"
|
28
28
|
|
data/app/models/spree/asset.rb
CHANGED
@@ -19,8 +19,9 @@ module Spree
|
|
19
19
|
|
20
20
|
def create_profile(payment)
|
21
21
|
# simulate the storage of credit card profile using remote service
|
22
|
-
success = VALID_CCS.include?
|
23
|
-
|
22
|
+
if success = VALID_CCS.include?(payment.source.number)
|
23
|
+
payment.source.update_attributes(:gateway_customer_profile_id => generate_profile_id(success))
|
24
|
+
end
|
24
25
|
end
|
25
26
|
|
26
27
|
def authorize(money, credit_card, options = {})
|
@@ -3,7 +3,7 @@ module Spree
|
|
3
3
|
belongs_to :variant, class_name: "Spree::Variant", inverse_of: :inventory_units
|
4
4
|
belongs_to :order, class_name: "Spree::Order", inverse_of: :inventory_units
|
5
5
|
belongs_to :shipment, class_name: "Spree::Shipment", touch: true, inverse_of: :inventory_units
|
6
|
-
belongs_to :return_authorization, class_name: "Spree::ReturnAuthorization"
|
6
|
+
belongs_to :return_authorization, class_name: "Spree::ReturnAuthorization", inverse_of: :inventory_units
|
7
7
|
belongs_to :line_item, class_name: "Spree::LineItem", inverse_of: :inventory_units
|
8
8
|
|
9
9
|
scope :backordered, -> { where state: 'backordered' }
|
@@ -72,7 +72,7 @@ module Spree
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def best_promotion_adjustment
|
75
|
-
@best_promotion_adjustment ||= adjustments.promotion.eligible.reorder("amount ASC, created_at DESC").first
|
75
|
+
@best_promotion_adjustment ||= adjustments.promotion.eligible.reorder("amount ASC, created_at DESC, id DESC").first
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
data/app/models/spree/order.rb
CHANGED
@@ -38,9 +38,9 @@ module Spree
|
|
38
38
|
alias_attribute :ship_total, :shipment_total
|
39
39
|
|
40
40
|
has_many :state_changes, as: :stateful
|
41
|
-
has_many :line_items, -> { order(
|
41
|
+
has_many :line_items, -> { order("#{LineItem.table_name}.created_at ASC") }, dependent: :destroy, inverse_of: :order
|
42
42
|
has_many :payments, dependent: :destroy
|
43
|
-
has_many :return_authorizations, dependent: :destroy
|
43
|
+
has_many :return_authorizations, dependent: :destroy, inverse_of: :order
|
44
44
|
has_many :adjustments, -> { order("#{Adjustment.table_name}.created_at ASC") }, as: :adjustable, dependent: :destroy
|
45
45
|
has_many :line_item_adjustments, through: :line_items, source: :adjustments
|
46
46
|
has_many :shipment_adjustments, through: :shipments, source: :adjustments
|
@@ -306,7 +306,11 @@ module Spree
|
|
306
306
|
end
|
307
307
|
|
308
308
|
def outstanding_balance
|
309
|
-
|
309
|
+
if self.state == 'canceled' && self.payments.present? && self.payments.completed.size > 0
|
310
|
+
-1 * payment_total
|
311
|
+
else
|
312
|
+
total - payment_total
|
313
|
+
end
|
310
314
|
end
|
311
315
|
|
312
316
|
def outstanding_balance?
|
@@ -424,6 +428,7 @@ module Spree
|
|
424
428
|
order.line_items.each do |line_item|
|
425
429
|
next unless line_item.currency == currency
|
426
430
|
current_line_item = self.line_items.find_by(variant: line_item.variant)
|
431
|
+
|
427
432
|
if current_line_item
|
428
433
|
current_line_item.quantity += line_item.quantity
|
429
434
|
current_line_item.save
|
@@ -628,9 +633,8 @@ module Spree
|
|
628
633
|
def after_cancel
|
629
634
|
shipments.each { |shipment| shipment.cancel! }
|
630
635
|
payments.completed.each { |payment| payment.cancel! }
|
631
|
-
|
632
636
|
send_cancel_email
|
633
|
-
self.
|
637
|
+
self.update!
|
634
638
|
end
|
635
639
|
|
636
640
|
def send_cancel_email
|
@@ -151,35 +151,20 @@ module Spree
|
|
151
151
|
#
|
152
152
|
# The +payment_state+ value helps with reporting, etc. since it provides a quick and easy way to locate Orders needing attention.
|
153
153
|
def update_payment_state
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
order.payment_state = 'pending'
|
162
|
-
elsif payments.last.state == 'completed'
|
163
|
-
if line_items.empty?
|
164
|
-
order.payment_state = 'credit_owed'
|
165
|
-
else
|
166
|
-
order.payment_state = 'balance_due'
|
167
|
-
end
|
168
|
-
elsif payments.last.state == 'pending'
|
169
|
-
order.payment_state = 'balance_due'
|
170
|
-
else
|
171
|
-
order.payment_state = 'credit_owed'
|
172
|
-
end
|
173
|
-
else
|
174
|
-
order.payment_state = 'balance_due'
|
175
|
-
end
|
176
|
-
elsif round_money(order.payment_total) > round_money(order.total)
|
177
|
-
order.payment_state = 'credit_owed'
|
154
|
+
last_state = order.payment_state
|
155
|
+
if payments.present? && payments.valid.size == 0
|
156
|
+
order.payment_state = 'failed'
|
157
|
+
elsif !payments.present? && order.state == 'canceled'
|
158
|
+
order.payment_state = 'void'
|
159
|
+
elsif order.state == 'canceled' && order.payment_total == 0 && payments.completed.size > 0
|
160
|
+
order.payment_state = 'void'
|
178
161
|
else
|
179
|
-
order.payment_state = '
|
162
|
+
order.payment_state = 'balance_due' if order.outstanding_balance > 0
|
163
|
+
order.payment_state = 'credit_owed' if order.outstanding_balance < 0
|
164
|
+
order.payment_state = 'paid' if !order.outstanding_balance?
|
180
165
|
end
|
181
|
-
|
182
|
-
order.
|
166
|
+
order.state_changed('payment') if last_state != order.payment_state
|
167
|
+
order.payment_state
|
183
168
|
end
|
184
169
|
|
185
170
|
private
|
data/app/models/spree/payment.rb
CHANGED
@@ -8,7 +8,7 @@ module Spree
|
|
8
8
|
|
9
9
|
belongs_to :order, class_name: 'Spree::Order', touch: true, inverse_of: :payments
|
10
10
|
belongs_to :source, polymorphic: true
|
11
|
-
belongs_to :payment_method, class_name: 'Spree::PaymentMethod'
|
11
|
+
belongs_to :payment_method, class_name: 'Spree::PaymentMethod', inverse_of: :payments
|
12
12
|
|
13
13
|
has_many :offsets, -> { where("source_type = 'Spree::Payment' AND amount < 0 AND state = 'completed'") },
|
14
14
|
class_name: "Spree::Payment", foreign_key: :source_id
|
@@ -166,7 +166,8 @@ module Spree
|
|
166
166
|
end
|
167
167
|
|
168
168
|
def create_payment_profile
|
169
|
-
return unless source.respond_to?(:has_payment_profile?) && !source.has_payment_profile?
|
169
|
+
return unless source.respond_to?(:has_payment_profile?) && !source.has_payment_profile? &&
|
170
|
+
state != 'invalid' && state != 'failed'
|
170
171
|
|
171
172
|
payment_method.create_profile(self)
|
172
173
|
rescue ActiveMerchant::ConnectionError => e
|
@@ -174,8 +175,10 @@ module Spree
|
|
174
175
|
end
|
175
176
|
|
176
177
|
def invalidate_old_payments
|
177
|
-
|
178
|
-
payment
|
178
|
+
if state != 'invalid' and state != 'failed'
|
179
|
+
order.payments.with_state('checkout').where("id != ?", self.id).each do |payment|
|
180
|
+
payment.invalidate!
|
181
|
+
end
|
179
182
|
end
|
180
183
|
end
|
181
184
|
|
@@ -8,7 +8,7 @@ module Spree
|
|
8
8
|
|
9
9
|
validates :name, presence: true
|
10
10
|
|
11
|
-
has_many :payments, class_name: "Spree::Payment"
|
11
|
+
has_many :payments, class_name: "Spree::Payment", inverse_of: :payment_method
|
12
12
|
has_many :credit_cards, class_name: "Spree::CreditCard"
|
13
13
|
|
14
14
|
def self.providers
|
data/app/models/spree/product.rb
CHANGED
@@ -39,9 +39,8 @@ module Spree
|
|
39
39
|
has_one :master,
|
40
40
|
-> { where is_master: true },
|
41
41
|
inverse_of: :product,
|
42
|
-
class_name: 'Spree::Variant'
|
43
|
-
|
44
|
-
|
42
|
+
class_name: 'Spree::Variant'
|
43
|
+
|
45
44
|
has_many :variants,
|
46
45
|
-> { where(is_master: false).order("#{::Spree::Variant.quoted_table_name}.position ASC") },
|
47
46
|
inverse_of: :product,
|
@@ -72,11 +72,15 @@ module Spree
|
|
72
72
|
end
|
73
73
|
}
|
74
74
|
|
75
|
+
# Check for applied adjustments.
|
75
76
|
discount = order.line_item_adjustments.promotion.detect(&detector)
|
76
77
|
discount ||= order.shipment_adjustments.promotion.detect(&detector)
|
77
78
|
discount ||= order.adjustments.promotion.detect(&detector)
|
78
79
|
|
79
|
-
|
80
|
+
# Check for applied line items.
|
81
|
+
created_line_items = promotion.actions.detect { |a| a.type == 'Spree::Promotion::Actions::CreateLineItems' }
|
82
|
+
|
83
|
+
if (discount && discount.eligible) || created_line_items
|
80
84
|
order.update_totals
|
81
85
|
order.persist_totals
|
82
86
|
self.success = Spree.t(:coupon_code_applied)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
class ReturnAuthorization < ActiveRecord::Base
|
3
|
-
belongs_to :order, class_name: 'Spree::Order'
|
3
|
+
belongs_to :order, class_name: 'Spree::Order', inverse_of: :return_authorizations
|
4
4
|
|
5
|
-
has_many :inventory_units, dependent: :nullify
|
5
|
+
has_many :inventory_units, dependent: :nullify, inverse_of: :return_authorization
|
6
6
|
belongs_to :stock_location
|
7
7
|
before_create :generate_number
|
8
8
|
before_save :force_positive_amount
|
@@ -2,7 +2,7 @@ module Spree
|
|
2
2
|
class ShippingCategory < ActiveRecord::Base
|
3
3
|
validates :name, presence: true
|
4
4
|
has_many :products, inverse_of: :shipping_category
|
5
|
-
has_many :shipping_method_categories
|
5
|
+
has_many :shipping_method_categories, inverse_of: :shipping_method
|
6
6
|
has_many :shipping_methods, through: :shipping_method_categories
|
7
7
|
end
|
8
|
-
end
|
8
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
class ShippingMethodCategory < ActiveRecord::Base
|
3
3
|
belongs_to :shipping_method, class_name: 'Spree::ShippingMethod'
|
4
|
-
belongs_to :shipping_category, class_name: 'Spree::ShippingCategory'
|
4
|
+
belongs_to :shipping_category, class_name: 'Spree::ShippingCategory', inverse_of: :shipping_method_categories
|
5
5
|
end
|
6
6
|
end
|
@@ -2,7 +2,7 @@ module Spree
|
|
2
2
|
class StockItem < ActiveRecord::Base
|
3
3
|
acts_as_paranoid
|
4
4
|
|
5
|
-
belongs_to :stock_location, class_name: 'Spree::StockLocation'
|
5
|
+
belongs_to :stock_location, class_name: 'Spree::StockLocation', inverse_of: :stock_items
|
6
6
|
belongs_to :variant, class_name: 'Spree::Variant', inverse_of: :stock_items
|
7
7
|
has_many :stock_movements, inverse_of: :stock_item
|
8
8
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class StockLocation < ActiveRecord::Base
|
3
3
|
has_many :shipments
|
4
|
-
has_many :stock_items, dependent: :delete_all
|
4
|
+
has_many :stock_items, dependent: :delete_all, inverse_of: :stock_location
|
5
5
|
has_many :stock_movements, through: :stock_items
|
6
6
|
|
7
7
|
belongs_to :state, class_name: 'Spree::State'
|
@@ -11,10 +11,15 @@ end
|
|
11
11
|
module Spree
|
12
12
|
class TaxRate < ActiveRecord::Base
|
13
13
|
acts_as_paranoid
|
14
|
+
|
15
|
+
# Need to deal with adjustments before calculator is destroyed.
|
16
|
+
before_destroy :deals_with_adjustments_for_deleted_source
|
17
|
+
|
14
18
|
include Spree::Core::CalculatedAdjustments
|
15
19
|
include Spree::Core::AdjustmentSource
|
16
|
-
|
17
|
-
belongs_to :
|
20
|
+
|
21
|
+
belongs_to :zone, class_name: "Spree::Zone", inverse_of: :tax_rates
|
22
|
+
belongs_to :tax_category, class_name: "Spree::TaxCategory", inverse_of: :tax_rates
|
18
23
|
|
19
24
|
has_many :adjustments, as: :source
|
20
25
|
|
@@ -22,8 +27,6 @@ module Spree
|
|
22
27
|
validates :tax_category_id, presence: true
|
23
28
|
validates_with DefaultTaxZoneValidator
|
24
29
|
|
25
|
-
before_destroy :deals_with_adjustments_for_deleted_source
|
26
|
-
|
27
30
|
scope :by_zone, ->(zone) { where(zone_id: zone) }
|
28
31
|
|
29
32
|
# Gets the array of TaxRates appropriate for the specified order
|
data/app/models/spree/variant.rb
CHANGED
@@ -9,7 +9,7 @@ module Spree
|
|
9
9
|
:shipping_category_id, :meta_description, :meta_keywords,
|
10
10
|
:shipping_category
|
11
11
|
|
12
|
-
has_many :inventory_units
|
12
|
+
has_many :inventory_units, inverse_of: :variant
|
13
13
|
has_many :line_items, inverse_of: :variant
|
14
14
|
|
15
15
|
has_many :stock_items, dependent: :destroy, inverse_of: :variant
|
data/app/models/spree/zone.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
class Zone < ActiveRecord::Base
|
3
|
-
has_many :zone_members, dependent: :destroy, class_name: "Spree::ZoneMember"
|
4
|
-
has_many :tax_rates, dependent: :destroy
|
3
|
+
has_many :zone_members, dependent: :destroy, class_name: "Spree::ZoneMember", inverse_of: :zone
|
4
|
+
has_many :tax_rates, dependent: :destroy, inverse_of: :zone
|
5
|
+
|
5
6
|
has_and_belongs_to_many :shipping_methods, :join_table => 'spree_shipping_methods_zones'
|
6
7
|
|
7
8
|
validates :name, presence: true, uniqueness: true
|
@@ -14,7 +15,7 @@ module Spree
|
|
14
15
|
def self.default_tax
|
15
16
|
where(default_tax: true).first
|
16
17
|
end
|
17
|
-
|
18
|
+
|
18
19
|
# Returns the matching zone with the highest priority zone type (State, Country, Zone.)
|
19
20
|
# Returns nil in the case of no matches.
|
20
21
|
def self.match(address)
|
@@ -91,23 +92,11 @@ module Spree
|
|
91
92
|
end
|
92
93
|
|
93
94
|
def country_ids=(ids)
|
94
|
-
|
95
|
-
ids.reject{ |id| id.blank? }.map do |id|
|
96
|
-
member = ZoneMember.new
|
97
|
-
member.zoneable_type = 'Spree::Country'
|
98
|
-
member.zoneable_id = id
|
99
|
-
members << member
|
100
|
-
end
|
95
|
+
set_zone_members(ids, 'Spree::Country')
|
101
96
|
end
|
102
97
|
|
103
98
|
def state_ids=(ids)
|
104
|
-
|
105
|
-
ids.reject{ |id| id.blank? }.map do |id|
|
106
|
-
member = ZoneMember.new
|
107
|
-
member.zoneable_type = 'Spree::State'
|
108
|
-
member.zoneable_id = id
|
109
|
-
members << member
|
110
|
-
end
|
99
|
+
set_zone_members(ids, 'Spree::State')
|
111
100
|
end
|
112
101
|
|
113
102
|
# Indicates whether the specified zone falls entirely within the zone performing
|
@@ -135,5 +124,15 @@ module Spree
|
|
135
124
|
def remove_previous_default
|
136
125
|
Spree::Zone.where('id != ?', self.id).update_all(default_tax: false) if default_tax
|
137
126
|
end
|
127
|
+
|
128
|
+
def set_zone_members(ids, type)
|
129
|
+
zone_members.destroy_all
|
130
|
+
ids.reject{ |id| id.blank? }.map do |id|
|
131
|
+
member = ZoneMember.new
|
132
|
+
member.zoneable_type = type
|
133
|
+
member.zoneable_id = id
|
134
|
+
members << member
|
135
|
+
end
|
136
|
+
end
|
138
137
|
end
|
139
138
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
class ZoneMember < ActiveRecord::Base
|
3
|
-
belongs_to :zone, class_name: 'Spree::Zone', counter_cache: true
|
3
|
+
belongs_to :zone, class_name: 'Spree::Zone', counter_cache: true, inverse_of: :zone_members
|
4
4
|
belongs_to :zoneable, polymorphic: true
|
5
5
|
|
6
6
|
def name
|
data/config/locales/en.yml
CHANGED
@@ -418,6 +418,7 @@ en:
|
|
418
418
|
back_to_users_list: Back To Users List
|
419
419
|
back_to_zones_list: Back To Zones List
|
420
420
|
backorderable: Backorderable
|
421
|
+
backorderable_default: Backorderable default
|
421
422
|
backorders_allowed: backorders allowed
|
422
423
|
balance_due: Balance Due
|
423
424
|
bill_address: Bill Address
|
@@ -800,6 +801,7 @@ en:
|
|
800
801
|
or_over_price: ! '%{price} or over'
|
801
802
|
order: Order
|
802
803
|
order_adjustments: Order adjustments
|
804
|
+
order_already_updated: The order has already been updated.
|
803
805
|
order_approved: Order approved
|
804
806
|
order_canceled: Order canceled
|
805
807
|
order_details: Order Details
|
@@ -950,6 +952,7 @@ en:
|
|
950
952
|
name: User Logged In
|
951
953
|
promotions: Promotions
|
952
954
|
promotion_uses: Promotion uses
|
955
|
+
propagate_all_variants: Propagate all variants
|
953
956
|
properties: Properties
|
954
957
|
property: Property
|
955
958
|
prototype: Prototype
|
data/db/migrate/20130611054351_rename_shipping_methods_zones_to_spree_shipping_methods_zones.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
class RenameShippingMethodsZonesToSpreeShippingMethodsZones < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
rename_table :shipping_methods_zones, :spree_shipping_methods_zones
|
4
|
+
# If Spree::ShippingMethod zones association was patched in
|
5
|
+
# CreateShippingMethodZone migrations, it needs to be patched back
|
6
|
+
Spree::ShippingMethod.has_and_belongs_to_many :zones, :join_table => 'spree_shipping_methods_zones',
|
7
|
+
:class_name => 'Spree::Zone',
|
8
|
+
:foreign_key => 'shipping_method_id'
|
4
9
|
end
|
5
10
|
end
|
@@ -3,10 +3,8 @@ class SetShipmentTotalForUsersUpgrading < ActiveRecord::Migration
|
|
3
3
|
# NOTE You might not need this at all unless you're upgrading from Spree 2.1.x
|
4
4
|
# or below. For those upgrading this should populate the Order#shipment_total
|
5
5
|
# for legacy orders
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
WHERE spree_shipments.order_id = spree_orders.id)
|
10
|
-
WHERE spree_orders.completed_at IS NOT NULL AND spree_orders.shipment_total = 0"
|
6
|
+
Spree::Order.complete.where('shipment_total = ?', 0).includes(:shipments).find_each do |order|
|
7
|
+
order.update_column(:shipment_total, order.shipments.sum(:cost))
|
8
|
+
end
|
11
9
|
end
|
12
10
|
end
|
@@ -57,14 +57,10 @@ User-agent: *
|
|
57
57
|
Disallow: /checkout
|
58
58
|
Disallow: /cart
|
59
59
|
Disallow: /orders
|
60
|
-
Disallow: /
|
61
|
-
Disallow: /line_items
|
62
|
-
Disallow: /password_resets
|
63
|
-
Disallow: /states
|
64
|
-
Disallow: /user_sessions
|
65
|
-
Disallow: /user_registrations
|
66
|
-
Disallow: /users
|
60
|
+
Disallow: /user
|
67
61
|
Disallow: /account
|
62
|
+
Disallow: /api
|
63
|
+
Disallow: /password
|
68
64
|
ROBOTS
|
69
65
|
end
|
70
66
|
|
@@ -8,7 +8,7 @@ module Spree
|
|
8
8
|
helper_method :try_spree_current_user
|
9
9
|
|
10
10
|
rescue_from CanCan::AccessDenied do |exception|
|
11
|
-
|
11
|
+
redirect_unauthorized_access
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -20,7 +20,7 @@ module Spree
|
|
20
20
|
# Redirect as appropriate when an access request fails. The default action is to redirect to the login screen.
|
21
21
|
# Override this method in your controllers if you want to have special behavior in case the user is not authorized
|
22
22
|
# to access the requested action. For example, a popup window might simply close itself.
|
23
|
-
def
|
23
|
+
def redirect_unauthorized_access
|
24
24
|
if try_spree_current_user
|
25
25
|
flash[:error] = Spree.t(:authorization_failure)
|
26
26
|
redirect_to '/unauthorized'
|
@@ -13,7 +13,9 @@ module Spree
|
|
13
13
|
order = Spree::Order.create!
|
14
14
|
order.associate_user!(user)
|
15
15
|
|
16
|
-
|
16
|
+
shipments_attrs = params.delete(:shipments_attributes)
|
17
|
+
|
18
|
+
create_shipments_from_params(shipments_attrs, order)
|
17
19
|
create_line_items_from_params(params.delete(:line_items_attributes),order)
|
18
20
|
create_adjustments_from_params(params.delete(:adjustments_attributes), order)
|
19
21
|
create_payments_from_params(params.delete(:payments_attributes), order)
|
@@ -30,8 +32,15 @@ module Spree
|
|
30
32
|
|
31
33
|
order.update_attributes!(params)
|
32
34
|
|
35
|
+
order.create_proposed_shipments unless shipments_attrs.present?
|
36
|
+
|
33
37
|
# Really ensure that the order totals & states are correct
|
34
38
|
order.updater.update
|
39
|
+
if shipments_attrs.present?
|
40
|
+
order.shipments.each_with_index do |shipment, index|
|
41
|
+
shipment.update_columns(cost: shipments_attrs[index][:cost].to_f) if shipments_attrs[index][:cost].present?
|
42
|
+
end
|
43
|
+
end
|
35
44
|
order.reload
|
36
45
|
rescue Exception => e
|
37
46
|
order.destroy if order && order.persisted?
|
@@ -45,7 +54,7 @@ module Spree
|
|
45
54
|
begin
|
46
55
|
shipment = order.shipments.build
|
47
56
|
shipment.tracking = s[:tracking]
|
48
|
-
shipment.stock_location = Spree::StockLocation.find_by_name!(s[:stock_location])
|
57
|
+
shipment.stock_location = Spree::StockLocation.find_by_admin_name(s[:stock_location]) || Spree::StockLocation.find_by_name!(s[:stock_location])
|
49
58
|
|
50
59
|
if s[:shipped_at].present?
|
51
60
|
shipment.shipped_at = s[:shipped_at]
|
@@ -79,12 +88,15 @@ module Spree
|
|
79
88
|
return {} unless line_items_hash
|
80
89
|
line_items_hash.each_key do |k|
|
81
90
|
begin
|
82
|
-
|
83
|
-
ensure_variant_id_from_params(
|
84
|
-
|
85
|
-
extra_params = line_item.except(:variant_id, :quantity)
|
91
|
+
extra_params = line_items_hash[k].except(:variant_id, :quantity, :sku)
|
92
|
+
line_item = ensure_variant_id_from_params(line_items_hash[k])
|
86
93
|
line_item = order.contents.add(Spree::Variant.find(line_item[:variant_id]), line_item[:quantity])
|
87
|
-
|
94
|
+
# Raise any errors with saving to prevent import succeeding with line items failing silently.
|
95
|
+
if extra_params.present?
|
96
|
+
line_item.update_attributes!(extra_params)
|
97
|
+
else
|
98
|
+
line_item.save!
|
99
|
+
end
|
88
100
|
rescue Exception => e
|
89
101
|
raise "Order import line items: #{e.message} #{line_item}"
|
90
102
|
end
|
@@ -124,10 +136,13 @@ module Spree
|
|
124
136
|
|
125
137
|
def self.ensure_variant_id_from_params(hash)
|
126
138
|
begin
|
139
|
+
sku = hash.delete(:sku)
|
127
140
|
unless hash[:variant_id].present?
|
128
|
-
hash[:variant_id] = Spree::Variant.active.find_by_sku!(
|
129
|
-
hash.delete(:sku)
|
141
|
+
hash[:variant_id] = Spree::Variant.active.find_by_sku!(sku).id
|
130
142
|
end
|
143
|
+
hash
|
144
|
+
rescue ActiveRecord::RecordNotFound => e
|
145
|
+
raise "Ensure order import variant: Variant w/SKU #{sku} not found."
|
131
146
|
rescue Exception => e
|
132
147
|
raise "Ensure order import variant: #{e.message} #{hash}"
|
133
148
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class EmailValidator < ActiveModel::EachValidator
|
2
2
|
def validate_each(record,attribute,value)
|
3
|
-
unless value =~ /\A[^@\s]
|
3
|
+
unless value =~ /\A([^@\.]|[^@\.]([^@\s]*)[^@\.])@([^@\s]+\.)+[^@\s]+\z/
|
4
4
|
record.errors.add(attribute, :invalid, {:value => value}.merge!(options))
|
5
5
|
end
|
6
6
|
end
|
data/lib/spree/core/version.rb
CHANGED
@@ -34,7 +34,9 @@ module Spree
|
|
34
34
|
:state => [:name, :abbr]
|
35
35
|
]
|
36
36
|
|
37
|
-
@@checkout_attributes = [
|
37
|
+
@@checkout_attributes = [
|
38
|
+
:coupon_code, :email, :shipping_method_id, :special_instructions, :use_billing
|
39
|
+
]
|
38
40
|
|
39
41
|
@@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]
|
40
42
|
|
@@ -3,7 +3,7 @@ FactoryGirl.define do
|
|
3
3
|
name 'Promo'
|
4
4
|
|
5
5
|
trait :with_line_item_adjustment do
|
6
|
-
|
6
|
+
transient do
|
7
7
|
adjustment_rate 10
|
8
8
|
end
|
9
9
|
|
@@ -18,7 +18,7 @@ FactoryGirl.define do
|
|
18
18
|
factory :promotion_with_item_adjustment, traits: [:with_line_item_adjustment]
|
19
19
|
|
20
20
|
trait :with_order_adjustment do
|
21
|
-
|
21
|
+
transient do
|
22
22
|
order_adjustment_amount 10
|
23
23
|
end
|
24
24
|
|
@@ -32,13 +32,13 @@ FactoryGirl.define do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
trait :with_item_total_rule do
|
35
|
-
|
35
|
+
transient do
|
36
36
|
item_total_threshold_amount 10
|
37
37
|
end
|
38
38
|
|
39
39
|
after(:create) do |promotion, evaluator|
|
40
40
|
rule = Spree::Promotion::Rules::ItemTotal.create!(
|
41
|
-
preferred_operator: 'gte',
|
41
|
+
preferred_operator: 'gte',
|
42
42
|
preferred_amount: evaluator.item_total_threshold_amount
|
43
43
|
)
|
44
44
|
promotion.rules << rule
|
@@ -1,7 +1,7 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
# must use build()
|
3
3
|
factory :stock_packer, class: Spree::Stock::Packer do
|
4
|
-
|
4
|
+
transient do
|
5
5
|
stock_location { build(:stock_location) }
|
6
6
|
contents []
|
7
7
|
end
|
@@ -10,7 +10,7 @@ FactoryGirl.define do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
factory :stock_package, class: Spree::Stock::Package do
|
13
|
-
|
13
|
+
transient do
|
14
14
|
stock_location { build(:stock_location) }
|
15
15
|
order { create(:order_with_line_items, line_items_count: 2) }
|
16
16
|
contents []
|
data/lib/tasks/core.rake
CHANGED
@@ -86,8 +86,8 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
|
|
86
86
|
end
|
87
87
|
|
88
88
|
if load_sample
|
89
|
-
#
|
90
|
-
|
89
|
+
# Reload models' attributes in case they were loaded in old migrations with wrong attributes
|
90
|
+
ActiveRecord::Base.descendants.each(&:reset_column_information)
|
91
91
|
Rake::Task["spree_sample:load"].invoke
|
92
92
|
end
|
93
93
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -254,14 +254,14 @@ dependencies:
|
|
254
254
|
requirements:
|
255
255
|
- - "~>"
|
256
256
|
- !ruby/object:Gem::Version
|
257
|
-
version: 4.0.
|
257
|
+
version: 4.0.12
|
258
258
|
type: :runtime
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
262
|
- - "~>"
|
263
263
|
- !ruby/object:Gem::Version
|
264
|
-
version: 4.0.
|
264
|
+
version: 4.0.12
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
266
|
name: ransack
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
@@ -609,6 +609,7 @@ files:
|
|
609
609
|
- db/migrate/20140609201656_add_deleted_at_to_spree_promotion_actions.rb
|
610
610
|
- db/migrate/20140616202624_remove_uncaptured_amount_from_spree_payments.rb
|
611
611
|
- db/migrate/20140804185157_add_default_to_shipment_cost.rb
|
612
|
+
- db/migrate/20141021194502_add_state_lock_version_to_order.rb
|
612
613
|
- db/seeds.rb
|
613
614
|
- lib/generators/spree/custom_user/custom_user_generator.rb
|
614
615
|
- lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
|