spree_core 2.1.4 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/spree/order/checkout.rb +8 -3
- data/app/models/spree/order.rb +3 -3
- data/app/models/spree/order_updater.rb +9 -3
- data/app/models/spree/payment.rb +7 -2
- data/app/models/spree/payment_method.rb +1 -1
- data/app/models/spree/price.rb +1 -0
- data/app/models/spree/promotion.rb +17 -14
- data/app/models/spree/return_authorization.rb +2 -1
- data/app/models/spree/shipping_method.rb +1 -1
- data/app/models/spree/variant.rb +19 -8
- data/config/locales/en.yml +16 -7
- data/db/migrate/20140129024326_add_deleted_at_to_spree_prices.rb +5 -0
- data/db/migrate/20140204192230_add_auto_capture_to_payment_methods.rb +5 -0
- data/db/migrate/20140205181631_default_variant_weight_to_zero.rb +11 -0
- data/lib/spree/core/controller_helpers/auth.rb +5 -12
- data/lib/spree/core/controller_helpers/order.rb +5 -3
- data/lib/spree/core/product_duplicator.rb +10 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/money.rb +1 -1
- data/lib/spree/promo/coupon_applicator.rb +6 -3
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 729f9d4f394bb9bbd17cf7dbb7142ae574a9183e
|
4
|
+
data.tar.gz: ae2d1dcd731873c1ae6523bf46a1eb6a63db882e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3527af7dec8d2acdf7736713929387e3c099fa6776227640bd9089d2a5814da0c0f41eb54a822e5b80662f9f41126aeea5f155b82c2bfbe8d3b6ba331737b2a
|
7
|
+
data.tar.gz: 238f664949e01954bf25eb9cf8cb14f1a5236b615100c8961d0ee445d9e712022e1527e19ce3ce27c1082751128d2b9f99cf2d6ee8108b5b6452108fedeab6d3
|
@@ -77,11 +77,16 @@ module Spree
|
|
77
77
|
|
78
78
|
before_transition :from => :cart, :do => :ensure_line_items_present
|
79
79
|
|
80
|
-
|
81
|
-
|
80
|
+
if states[:address]
|
81
|
+
before_transition :from => :address, :do => :create_tax_charge!
|
82
|
+
end
|
83
|
+
|
84
|
+
if states[:delivery]
|
85
|
+
before_transition :to => :delivery, :do => :create_proposed_shipments
|
86
|
+
before_transition :to => :delivery, :do => :ensure_available_shipping_rates
|
87
|
+
end
|
82
88
|
|
83
89
|
after_transition :to => :complete, :do => :finalize!
|
84
|
-
after_transition :to => :delivery, :do => :create_tax_charge!
|
85
90
|
after_transition :to => :resumed, :do => :after_resume
|
86
91
|
after_transition :to => :canceled, :do => :after_cancel
|
87
92
|
end
|
data/app/models/spree/order.rb
CHANGED
@@ -528,9 +528,9 @@ module Spree
|
|
528
528
|
|
529
529
|
def is_risky?
|
530
530
|
self.payments.where(%{
|
531
|
-
(avs_response IS NOT NULL and avs_response != 'D') or
|
531
|
+
(avs_response IS NOT NULL and avs_response != '' and avs_response != 'D' and avs_response != 'M') or
|
532
532
|
(cvv_response_code IS NOT NULL and cvv_response_code != 'M') or
|
533
|
-
cvv_response_message IS NOT NULL or
|
533
|
+
cvv_response_message IS NOT NULL and cvv_response_message != '' or
|
534
534
|
state = 'failed'
|
535
535
|
}.squish!).uniq.count > 0
|
536
536
|
end
|
@@ -566,7 +566,7 @@ module Spree
|
|
566
566
|
end
|
567
567
|
|
568
568
|
def has_available_payment
|
569
|
-
return unless delivery?
|
569
|
+
return unless has_step?("delivery") && delivery?
|
570
570
|
# errors.add(:base, :no_payment_methods_available) if available_payment_methods.empty?
|
571
571
|
end
|
572
572
|
|
@@ -102,10 +102,16 @@ module Spree
|
|
102
102
|
# The +payment_state+ value helps with reporting, etc. since it provides a quick and easy way to locate Orders needing attention.
|
103
103
|
def update_payment_state
|
104
104
|
|
105
|
-
#line_item are empty when user empties cart
|
105
|
+
# line_item are empty when user empties cart
|
106
106
|
if line_items.empty? || round_money(order.payment_total) < round_money(order.total)
|
107
|
-
if payments.present?
|
108
|
-
|
107
|
+
if payments.present?
|
108
|
+
if payments.last.state == 'failed'
|
109
|
+
order.payment_state = 'failed'
|
110
|
+
elsif payments.last.state == 'completed'
|
111
|
+
order.payment_state = 'credit_owed'
|
112
|
+
else
|
113
|
+
order.payment_state = 'balance_due'
|
114
|
+
end
|
109
115
|
else
|
110
116
|
order.payment_state = 'balance_due'
|
111
117
|
end
|
data/app/models/spree/payment.rb
CHANGED
@@ -119,11 +119,16 @@ module Spree
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def is_avs_risky?
|
122
|
-
|
122
|
+
return false if avs_response == "D"
|
123
|
+
return false if avs_response.blank?
|
124
|
+
return true
|
123
125
|
end
|
124
126
|
|
125
127
|
def is_cvv_risky?
|
126
|
-
|
128
|
+
return false if cvv_response_code == "M"
|
129
|
+
return false if cvv_response_code.nil?
|
130
|
+
return false if cvv_response_message.present?
|
131
|
+
return true
|
127
132
|
end
|
128
133
|
|
129
134
|
private
|
data/app/models/spree/price.rb
CHANGED
@@ -30,21 +30,24 @@ module Spree
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def activate(payload)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
33
|
+
if order_activatable?(payload[:order]) && eligible?(payload[:order])
|
34
|
+
# make sure code is always downcased (old databases might have mixed case codes)
|
35
|
+
if code.present?
|
36
|
+
event_code = payload[:coupon_code]
|
37
|
+
return unless event_code == self.code.downcase.strip
|
38
|
+
end
|
39
|
+
|
40
|
+
if path.present?
|
41
|
+
return unless path == payload[:path]
|
42
|
+
end
|
43
|
+
|
44
|
+
actions.each do |action|
|
45
|
+
action.perform(payload)
|
46
|
+
end
|
47
|
+
|
48
|
+
return true
|
47
49
|
end
|
50
|
+
false
|
48
51
|
end
|
49
52
|
|
50
53
|
# called anytime order.update! happens
|
@@ -78,7 +78,8 @@ module Spree
|
|
78
78
|
def process_return
|
79
79
|
inventory_units.each do |iu|
|
80
80
|
iu.return!
|
81
|
-
Spree::
|
81
|
+
stock_item = Spree::StockItem.where(variant_id: iu.variant.id, stock_location_id: stock_location_id).first
|
82
|
+
Spree::StockMovement.create!(stock_item_id: stock_item.id, quantity: 1)
|
82
83
|
end
|
83
84
|
|
84
85
|
credit = Adjustment.new(amount: amount.abs * -1, label: Spree.t(:rma_credit))
|
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
default_scope -> { where(deleted_at: nil) }
|
7
7
|
|
8
8
|
has_many :shipments
|
9
|
-
has_many :shipping_method_categories
|
9
|
+
has_many :shipping_method_categories, :dependent => :destroy
|
10
10
|
has_many :shipping_categories, through: :shipping_method_categories
|
11
11
|
has_many :shipping_rates, inverse_of: :shipping_method
|
12
12
|
|
data/app/models/spree/variant.rb
CHANGED
@@ -30,7 +30,7 @@ module Spree
|
|
30
30
|
dependent: :destroy
|
31
31
|
|
32
32
|
validate :check_price
|
33
|
-
validates :price, numericality: { greater_than_or_equal_to: 0 }
|
33
|
+
validates :price, numericality: { greater_than_or_equal_to: 0 }
|
34
34
|
|
35
35
|
validates :cost_price, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
|
36
36
|
|
@@ -56,7 +56,9 @@ module Spree
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def options_text
|
59
|
-
values = self.option_values.
|
59
|
+
values = self.option_values.sort do |a, b|
|
60
|
+
a.option_type.position <=> b.option_type.position
|
61
|
+
end
|
60
62
|
|
61
63
|
values.map! do |ov|
|
62
64
|
"#{ov.option_type.presentation}: #{ov.presentation}"
|
@@ -76,6 +78,17 @@ module Spree
|
|
76
78
|
deleted_at
|
77
79
|
end
|
78
80
|
|
81
|
+
# Product may be created with deleted_at already set,
|
82
|
+
# which would make AR's default finder return nil.
|
83
|
+
# This is a stopgap for that little problem.
|
84
|
+
def product
|
85
|
+
Spree::Product.unscoped { super }
|
86
|
+
end
|
87
|
+
|
88
|
+
def default_price
|
89
|
+
Spree::Price.unscoped { super }
|
90
|
+
end
|
91
|
+
|
79
92
|
def options=(options = {})
|
80
93
|
options.each do |option|
|
81
94
|
set_option_value(option[:name], option[:value])
|
@@ -136,14 +149,12 @@ module Spree
|
|
136
149
|
"#{sku} #{options_text}".strip
|
137
150
|
end
|
138
151
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
def product
|
143
|
-
Spree::Product.unscoped { super }
|
152
|
+
def in_stock?(quantity=1)
|
153
|
+
puts %q{[DEPRECATION] In Spree 2.2, Variant#in_stock? will no longer take a quantity. Use Variant#can_supply? instead.}
|
154
|
+
can_stock?(quantity)
|
144
155
|
end
|
145
156
|
|
146
|
-
def
|
157
|
+
def can_stock?(quantity=1)
|
147
158
|
Spree::Stock::Quantifier.new(self).can_supply?(quantity)
|
148
159
|
end
|
149
160
|
|
data/config/locales/en.yml
CHANGED
@@ -318,13 +318,18 @@ en:
|
|
318
318
|
delivery_success: Test Mail sent successfully
|
319
319
|
error: ! 'Test Mail error: %{e}'
|
320
320
|
tab:
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
promotions:
|
327
|
-
|
321
|
+
configuration: Configuration
|
322
|
+
option_types: Option Types
|
323
|
+
orders: Orders
|
324
|
+
overview: Overview
|
325
|
+
products: Products
|
326
|
+
promotions: Promotions
|
327
|
+
properties: Properties
|
328
|
+
prototypes: Prototypes
|
329
|
+
reports: Reports
|
330
|
+
taxonomies: Taxonomies
|
331
|
+
taxons: Taxons
|
332
|
+
users: Users
|
328
333
|
administration: Administration
|
329
334
|
agree_to_privacy_policy: Agree to Privacy Policy
|
330
335
|
agree_to_terms_of_service: Agree to Terms of Service
|
@@ -356,6 +361,7 @@ en:
|
|
356
361
|
attachment_styles: Paperclip Styles
|
357
362
|
attachment_url: Attachments URL
|
358
363
|
authorization_failure: Authorization Failure
|
364
|
+
auto_capture: Auto Capture
|
359
365
|
available_on: Available On
|
360
366
|
avs_response: AVS Response
|
361
367
|
back: Back
|
@@ -600,6 +606,7 @@ en:
|
|
600
606
|
image_settings_updated: Image Settings successfully updated.
|
601
607
|
image_settings_warning: You will need to regenerate thumbnails if you update the paperclip styles. Use rake paperclip:refresh:thumbnails CLASS=Spree::Image to do this.
|
602
608
|
images: Images
|
609
|
+
inactive: Inactive
|
603
610
|
included_in_price: Included in Price
|
604
611
|
included_price_validation: cannot be selected unless you have set a Default Tax Zone
|
605
612
|
instructions_to_reset_password: Please enter your email on the form below
|
@@ -926,6 +933,7 @@ en:
|
|
926
933
|
review: Review
|
927
934
|
risk: Risk
|
928
935
|
risk_analysis: Risk Analysis
|
936
|
+
risky: Risky
|
929
937
|
rma_credit: RMA Credit
|
930
938
|
rma_number: RMA Number
|
931
939
|
rma_value: RMA Value
|
@@ -1094,6 +1102,7 @@ en:
|
|
1094
1102
|
update: Update
|
1095
1103
|
updating: Updating
|
1096
1104
|
usage_limit: Usage Limit
|
1105
|
+
use_app_default: Use App Default
|
1097
1106
|
use_billing_address: Use Billing Address
|
1098
1107
|
use_new_cc: Use a new card
|
1099
1108
|
use_s3: Use Amazon S3 For Images
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class DefaultVariantWeightToZero < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
Spree::Variant.unscoped.where(weight: nil).update_all("weight = 0.0")
|
4
|
+
|
5
|
+
change_column :spree_variants, :weight, :decimal, precision: 8, scale: 2, default: 0.0
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
change_column :spree_variants, :weight, :decimal, precision: 8, scale: 2
|
10
|
+
end
|
11
|
+
end
|
@@ -5,7 +5,6 @@ module Spree
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
before_filter :ensure_api_key
|
9
8
|
helper_method :try_spree_current_user
|
10
9
|
|
11
10
|
rescue_from CanCan::AccessDenied do |exception|
|
@@ -27,7 +26,11 @@ module Spree
|
|
27
26
|
redirect_to '/unauthorized'
|
28
27
|
else
|
29
28
|
store_location
|
30
|
-
|
29
|
+
if respond_to?(:spree_login_path)
|
30
|
+
redirect_to spree_login_path
|
31
|
+
else
|
32
|
+
redirect_to spree.respond_to?(:root_path) ? spree.root_path : root_path
|
33
|
+
end
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
@@ -57,16 +60,6 @@ module Spree
|
|
57
60
|
redirect_to(session["spree_user_return_to"] || default)
|
58
61
|
session["spree_user_return_to"] = nil
|
59
62
|
end
|
60
|
-
|
61
|
-
# Need to generate an API key for a user due to some actions potentially
|
62
|
-
# requiring authentication to the Spree API
|
63
|
-
def ensure_api_key
|
64
|
-
if user = try_spree_current_user
|
65
|
-
if user.respond_to?(:spree_api_key) && user.spree_api_key.blank?
|
66
|
-
user.generate_spree_api_key!
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
63
|
end
|
71
64
|
end
|
72
65
|
end
|
@@ -11,15 +11,17 @@ module Spree
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# The current incomplete order from the session for use in cart and during checkout
|
14
|
-
def current_order(
|
14
|
+
def current_order(options = {})
|
15
|
+
options[:create_order_if_necessary] ||= false
|
16
|
+
options[:lock] ||= false
|
15
17
|
return @current_order if @current_order
|
16
18
|
|
17
19
|
if session[:order_id]
|
18
|
-
current_order = Spree::Order.includes(:adjustments).find_by(id: session[:order_id], currency: current_currency)
|
20
|
+
current_order = Spree::Order.includes(:adjustments).lock(options[:lock]).find_by(id: session[:order_id], currency: current_currency)
|
19
21
|
@current_order = current_order unless current_order.try(:completed?)
|
20
22
|
end
|
21
23
|
|
22
|
-
if create_order_if_necessary and (@current_order.nil? or @current_order.completed?)
|
24
|
+
if options[:create_order_if_necessary] and (@current_order.nil? or @current_order.completed?)
|
23
25
|
@current_order = Spree::Order.new(currency: current_currency)
|
24
26
|
@current_order.user ||= try_spree_current_user
|
25
27
|
# See issue #3346 for reasons why this line is here
|
@@ -23,12 +23,14 @@ module Spree
|
|
23
23
|
def duplicate_product
|
24
24
|
product.dup.tap do |new_product|
|
25
25
|
new_product.name = "COPY OF #{product.name}"
|
26
|
+
new_product.permalink = "copy-of-#{product.permalink}"
|
26
27
|
new_product.taxons = product.taxons
|
27
28
|
new_product.created_at = nil
|
28
29
|
new_product.deleted_at = nil
|
29
30
|
new_product.updated_at = nil
|
30
31
|
new_product.product_properties = reset_properties
|
31
32
|
new_product.master = duplicate_master
|
33
|
+
new_product.variants = product.variants.map { |variant| duplicate_variant variant }
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -43,6 +45,14 @@ module Spree
|
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
48
|
+
def duplicate_variant(variant)
|
49
|
+
new_variant = variant.dup
|
50
|
+
new_variant.sku = "COPY OF #{new_variant.sku}"
|
51
|
+
new_variant.deleted_at = nil
|
52
|
+
new_variant.option_values = variant.option_values.map { |option_value| option_value.dup}
|
53
|
+
new_variant
|
54
|
+
end
|
55
|
+
|
46
56
|
def duplicate_image(image)
|
47
57
|
new_image = image.dup
|
48
58
|
new_image.assign_attributes(:attachment => image.attachment.clone)
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/money.rb
CHANGED
@@ -199,7 +199,7 @@ module Spree
|
|
199
199
|
if options[:html]
|
200
200
|
# 1) prevent blank, breaking spaces
|
201
201
|
# 2) prevent escaping of HTML character entities
|
202
|
-
output = output.
|
202
|
+
output = output.sub(" ", " ").html_safe
|
203
203
|
end
|
204
204
|
output
|
205
205
|
end
|
@@ -32,9 +32,12 @@ module Spree
|
|
32
32
|
return promotion_usage_limit_exceeded if promotion.usage_limit_exceeded?
|
33
33
|
|
34
34
|
event_name = "spree.checkout.coupon_code_added"
|
35
|
-
promotion.activate(:coupon_code => @order.coupon_code, :order => @order)
|
36
|
-
|
37
|
-
|
35
|
+
if promotion.activate(:coupon_code => @order.coupon_code, :order => @order)
|
36
|
+
promo = @order.adjustments.includes(:originator).promotion.detect { |p| p.originator.promotion.code == @order.coupon_code }
|
37
|
+
determine_promotion_application_result(promo)
|
38
|
+
else
|
39
|
+
return { :coupon_applied? => false, :error => Spree.t(:coupon_code_not_eligible) }
|
40
|
+
end
|
38
41
|
end
|
39
42
|
|
40
43
|
def promotion_expired
|
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.1.
|
4
|
+
version: 2.1.5
|
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-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -511,6 +511,9 @@ files:
|
|
511
511
|
- db/migrate/20131120234456_add_updated_at_to_variants.rb
|
512
512
|
- db/migrate/20131211192741_unique_shipping_method_categories.rb
|
513
513
|
- db/migrate/20140120160805_add_index_to_variant_id_and_currency_on_prices.rb
|
514
|
+
- db/migrate/20140129024326_add_deleted_at_to_spree_prices.rb
|
515
|
+
- db/migrate/20140204192230_add_auto_capture_to_payment_methods.rb
|
516
|
+
- db/migrate/20140205181631_default_variant_weight_to_zero.rb
|
514
517
|
- db/seeds.rb
|
515
518
|
- lib/generators/spree/custom_user/custom_user_generator.rb
|
516
519
|
- lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
|