spree_core 3.0.0.rc1 → 3.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/spree/user_reporting.rb +2 -2
- data/app/models/spree/ability.rb +4 -1
- data/app/models/spree/adjustable/promotion_accumulator.rb +1 -1
- data/app/models/spree/return_authorization.rb +6 -2
- data/app/models/spree/return_item.rb +1 -1
- data/app/models/spree/role.rb +2 -0
- data/app/models/spree/stock_location.rb +5 -11
- data/app/models/spree/store.rb +4 -2
- data/app/models/spree/taxonomy.rb +2 -0
- data/app/models/spree/variant.rb +4 -0
- data/config/initializers/user_class_extensions.rb +2 -2
- data/config/locales/en.yml +5 -0
- data/db/migrate/20150216173445_add_index_to_spree_stock_items_variant_id.rb +13 -0
- data/lib/generators/spree/dummy/templates/rails/database.yml +1 -1
- data/lib/spree/core/importer/order.rb +64 -14
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/testing_support/controller_requests.rb +7 -2
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8039d6ead846bc4fa735aa26d8388a62d5c86a3c
|
4
|
+
data.tar.gz: 5ee17fff4d41214804b660bbf57f528d8f65855a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ed7452b11a0af1096c325d9f63eaf74bc928e82acce258d3fa5e46d5a9cc3b0d3a5a5251bb84ebb1e7732f1ea4038ed06dee1c0f83476e0055df4f69bec9f7d
|
7
|
+
data.tar.gz: 6d904ef3437a05af9bbe5355a566f9659c5828ccf19d57e0a1ef0be9829085d47e4129ab8b908fa688fcc2258049168fe021dd253e2f0313b9907b04e55dade8
|
@@ -4,11 +4,11 @@ module Spree
|
|
4
4
|
money_methods :lifetime_value, :average_order_value
|
5
5
|
|
6
6
|
def lifetime_value
|
7
|
-
|
7
|
+
orders.complete.pluck(:total).sum
|
8
8
|
end
|
9
9
|
|
10
10
|
def order_count
|
11
|
-
BigDecimal(
|
11
|
+
BigDecimal(orders.complete.count)
|
12
12
|
end
|
13
13
|
|
14
14
|
def average_order_value
|
data/app/models/spree/ability.rb
CHANGED
@@ -32,7 +32,7 @@ module Spree
|
|
32
32
|
alias_action :new_action, to: :create
|
33
33
|
alias_action :show, to: :read
|
34
34
|
alias_action :index, :read, to: :display
|
35
|
-
|
35
|
+
alias_action :create, :update, :destroy, to: :modify
|
36
36
|
|
37
37
|
user ||= Spree.user_class.new
|
38
38
|
|
@@ -64,6 +64,9 @@ module Spree
|
|
64
64
|
ability = clazz.send(:new, user)
|
65
65
|
@rules = rules + ability.send(:rules)
|
66
66
|
end
|
67
|
+
|
68
|
+
# Protect admin and user roles
|
69
|
+
cannot [:update, :destroy], Role, name: ['admin']
|
67
70
|
end
|
68
71
|
end
|
69
72
|
end
|
@@ -30,7 +30,7 @@ module Spree
|
|
30
30
|
add(promotions, promotion, source.promotion_id)
|
31
31
|
end
|
32
32
|
|
33
|
-
def promotions_adjustments(promotion_id, adjustments = adjustments)
|
33
|
+
def promotions_adjustments(promotion_id, adjustments = adjustments())
|
34
34
|
where(sources, promotion_id: promotion_id).map do |source|
|
35
35
|
where(adjustments, source_id: source.id)
|
36
36
|
end.flatten
|
@@ -29,7 +29,7 @@ module Spree
|
|
29
29
|
before_transition to: :canceled, do: :cancel_return_items
|
30
30
|
|
31
31
|
event :cancel do
|
32
|
-
transition to: :canceled, from: :authorized
|
32
|
+
transition to: :canceled, from: :authorized, if: lambda { |return_authorization| return_authorization.can_cancel_return_items? }
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
@@ -53,6 +53,10 @@ module Spree
|
|
53
53
|
customer_returns.exists?
|
54
54
|
end
|
55
55
|
|
56
|
+
def can_cancel_return_items?
|
57
|
+
return_items.any?(&:can_cancel?) || return_items.blank?
|
58
|
+
end
|
59
|
+
|
56
60
|
private
|
57
61
|
|
58
62
|
def must_have_shipped_units
|
@@ -69,7 +73,7 @@ module Spree
|
|
69
73
|
end
|
70
74
|
|
71
75
|
def cancel_return_items
|
72
|
-
return_items.each
|
76
|
+
return_items.each { |item| item.cancel! if item.can_cancel? }
|
73
77
|
end
|
74
78
|
|
75
79
|
def generate_expedited_exchange_reimbursements
|
data/app/models/spree/role.rb
CHANGED
@@ -41,21 +41,15 @@ module Spree
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# Attempts to look up StockItem for the variant, and creates one if not found.
|
44
|
-
# This method accepts an
|
45
|
-
#
|
44
|
+
# This method accepts an instance of the variant.
|
45
|
+
# Other methods in this model attempt to pass a variant,
|
46
46
|
# but controller actions can pass just the variant id as a parameter.
|
47
47
|
#
|
48
|
-
# @param
|
48
|
+
# @param variant [Variant] Variant instance.
|
49
49
|
#
|
50
50
|
# @return [StockItem] Corresponding StockItem for the StockLocation's variant.
|
51
|
-
def stock_item_or_create(
|
52
|
-
|
53
|
-
variant_or_id.id
|
54
|
-
else
|
55
|
-
ActiveSupport::Deprecation.warn "Passing a Variant ID is deprecated, and will be removed in Spree 3. Please pass a variant instance instead.", caller
|
56
|
-
variant_or_id
|
57
|
-
end
|
58
|
-
stock_item(vid) || stock_items.create(variant_id: vid)
|
51
|
+
def stock_item_or_create(variant)
|
52
|
+
stock_item(variant) || stock_items.create(variant_id: variant.id)
|
59
53
|
end
|
60
54
|
|
61
55
|
def count_on_hand(variant)
|
data/app/models/spree/store.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module Spree
|
2
2
|
class Store < Spree::Base
|
3
|
+
has_many :orders, class_name: "Spree::Order"
|
4
|
+
|
3
5
|
validates :code, presence: true, uniqueness: { allow_blank: true }
|
4
6
|
validates :name, presence: true
|
5
7
|
validates :url, presence: true
|
6
8
|
validates :mail_from_address, presence: true
|
7
9
|
|
8
|
-
|
10
|
+
before_save :ensure_default_exists_and_is_unique
|
9
11
|
before_destroy :validate_not_default
|
10
12
|
|
11
13
|
scope :by_url, lambda { |url| where("url like ?", "%#{url}%") }
|
@@ -23,7 +25,7 @@ module Spree
|
|
23
25
|
|
24
26
|
def ensure_default_exists_and_is_unique
|
25
27
|
if default
|
26
|
-
Store.update_all(default: false)
|
28
|
+
Store.where.not(id: id).update_all(default: false)
|
27
29
|
elsif Store.where(default: true).count == 0
|
28
30
|
self.default = true
|
29
31
|
end
|
data/app/models/spree/variant.rb
CHANGED
@@ -89,6 +89,10 @@ module Spree
|
|
89
89
|
is_master? ? name : options_text
|
90
90
|
end
|
91
91
|
|
92
|
+
def descriptive_name
|
93
|
+
is_master? ? name + ' - Master' : name + ' - ' + options_text
|
94
|
+
end
|
95
|
+
|
92
96
|
# use deleted? rather than checking the attribute directly. this
|
93
97
|
# allows extensions to override deleted? if they want to provide
|
94
98
|
# their own definition.
|
@@ -10,7 +10,7 @@ Spree::Core::Engine.config.to_prepare do
|
|
10
10
|
foreign_key: "user_id",
|
11
11
|
class_name: "Spree::Role"
|
12
12
|
|
13
|
-
has_many :
|
13
|
+
has_many :orders, foreign_key: :user_id, class_name: "Spree::Order"
|
14
14
|
|
15
15
|
belongs_to :ship_address, class_name: 'Spree::Address'
|
16
16
|
belongs_to :bill_address, class_name: 'Spree::Address'
|
@@ -21,7 +21,7 @@ Spree::Core::Engine.config.to_prepare do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def last_incomplete_spree_order
|
24
|
-
|
24
|
+
orders.incomplete.order('created_at DESC').first
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/config/locales/en.yml
CHANGED
@@ -404,6 +404,7 @@ en:
|
|
404
404
|
add_to_cart: Add To Cart
|
405
405
|
add_variant: Add Variant
|
406
406
|
additional_item: Additional Item
|
407
|
+
address: Address
|
407
408
|
address1: Address
|
408
409
|
address2: Address (contd.)
|
409
410
|
adjustable: Adjustable
|
@@ -605,6 +606,7 @@ en:
|
|
605
606
|
default_tax: Default Tax
|
606
607
|
default_tax_zone: Default Tax Zone
|
607
608
|
delete: Delete
|
609
|
+
delete_from_taxon: Delete From Taxon
|
608
610
|
deleted_variants_present: Some line items in this order have products that are no longer available.
|
609
611
|
delivery: Delivery
|
610
612
|
depth: Depth
|
@@ -825,6 +827,7 @@ en:
|
|
825
827
|
new_refund_reason: New Refund Reason
|
826
828
|
new_rma_reason: New RMA Reason
|
827
829
|
new_return_authorization: New Return Authorization
|
830
|
+
new_role: New Role
|
828
831
|
new_shipping_category: New Shipping Category
|
829
832
|
new_shipping_method: New Shipping Method
|
830
833
|
new_shipment_at_location: New shipment at location
|
@@ -1013,6 +1016,7 @@ en:
|
|
1013
1016
|
description: Makes all shipments for the order free
|
1014
1017
|
name: Free shipping
|
1015
1018
|
promotion_actions: Actions
|
1019
|
+
promotion_category: Promotion Category
|
1016
1020
|
promotion_form:
|
1017
1021
|
match_policies:
|
1018
1022
|
all: Match all of these rules
|
@@ -1130,6 +1134,7 @@ en:
|
|
1130
1134
|
rma_credit: RMA Credit
|
1131
1135
|
rma_number: RMA Number
|
1132
1136
|
rma_value: RMA Value
|
1137
|
+
role_id: Role ID
|
1133
1138
|
roles: Roles
|
1134
1139
|
rules: Rules
|
1135
1140
|
safe: Safe
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class AddIndexToSpreeStockItemsVariantId < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
unless index_exists? :spree_stock_items, :variant_id
|
4
|
+
add_index :spree_stock_items, :variant_id
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
if index_exists? :spree_stock_items, :variant_id
|
10
|
+
remove_index :spree_stock_items, :variant_id
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -27,7 +27,7 @@ production:
|
|
27
27
|
database: <%= database_prefix %><%= options[:lib_name] %>_spree_production
|
28
28
|
encoding: utf8
|
29
29
|
<% when 'postgres' %>
|
30
|
-
<% db_host = ENV['DB_HOST']
|
30
|
+
<% db_host = ENV['DB_HOST'] %>
|
31
31
|
development:
|
32
32
|
adapter: postgresql
|
33
33
|
database: <%= database_prefix %><%= options[:lib_name] %>_spree_development
|
@@ -97,21 +97,71 @@ module Spree
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
def self.create_line_items_from_params(
|
101
|
-
return {} unless
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
100
|
+
def self.create_line_items_from_params(line_items, order)
|
101
|
+
return {} unless line_items
|
102
|
+
case line_items
|
103
|
+
when Hash
|
104
|
+
ActiveSupport::Deprecation.warn(<<-EOS, caller)
|
105
|
+
Passing a hash is now deprecated and will be removed in Spree 3.1.
|
106
|
+
It is recommended that you pass it as an array instead.
|
107
|
+
|
108
|
+
New Syntax:
|
109
|
+
|
110
|
+
{
|
111
|
+
"order": {
|
112
|
+
"line_items": [
|
113
|
+
{ "variant_id": 123, "quantity": 1 },
|
114
|
+
{ "variant_id": 456, "quantity": 1 }
|
115
|
+
]
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
Old Syntax:
|
120
|
+
|
121
|
+
{
|
122
|
+
"order": {
|
123
|
+
"line_items": {
|
124
|
+
"1": { "variant_id": 123, "quantity": 1 },
|
125
|
+
"2": { "variant_id": 123, "quantity": 1 }
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
EOS
|
130
|
+
|
131
|
+
line_items.each_key do |k|
|
132
|
+
begin
|
133
|
+
extra_params = line_items[k].except(:variant_id, :quantity, :sku)
|
134
|
+
line_item = ensure_variant_id_from_params(line_items[k])
|
135
|
+
variant = Spree::Variant.find(line_item[:variant_id])
|
136
|
+
line_item = order.contents.add(variant, line_item[:quantity])
|
137
|
+
# Raise any errors with saving to prevent import succeeding with line items
|
138
|
+
# failing silently.
|
139
|
+
if extra_params.present?
|
140
|
+
line_item.update_attributes!(extra_params)
|
141
|
+
else
|
142
|
+
line_item.save!
|
143
|
+
end
|
144
|
+
rescue Exception => e
|
145
|
+
raise "Order import line items: #{e.message} #{line_item}"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
when Array
|
149
|
+
line_items.each do |line_item|
|
150
|
+
begin
|
151
|
+
extra_params = line_item.except(:variant_id, :quantity, :sku)
|
152
|
+
line_item = ensure_variant_id_from_params(line_item)
|
153
|
+
variant = Spree::Variant.find(line_item[:variant_id])
|
154
|
+
line_item = order.contents.add(variant, line_item[:quantity])
|
155
|
+
# Raise any errors with saving to prevent import succeeding with line items
|
156
|
+
# failing silently.
|
157
|
+
if extra_params.present?
|
158
|
+
line_item.update_attributes!(extra_params)
|
159
|
+
else
|
160
|
+
line_item.save!
|
161
|
+
end
|
162
|
+
rescue Exception => e
|
163
|
+
raise "Order import line items: #{e.message} #{line_item}"
|
112
164
|
end
|
113
|
-
rescue Exception => e
|
114
|
-
raise "Order import line items: #{e.message} #{line_item}"
|
115
165
|
end
|
116
166
|
end
|
117
167
|
end
|
data/lib/spree/core/version.rb
CHANGED
@@ -26,6 +26,12 @@
|
|
26
26
|
module Spree
|
27
27
|
module TestingSupport
|
28
28
|
module ControllerRequests
|
29
|
+
extend ActiveSupport::Concern
|
30
|
+
|
31
|
+
included do
|
32
|
+
routes { Spree::Core::Engine.routes }
|
33
|
+
end
|
34
|
+
|
29
35
|
def spree_get(action, parameters = nil, session = nil, flash = nil)
|
30
36
|
process_spree_action(action, parameters, session, flash, "GET")
|
31
37
|
end
|
@@ -65,13 +71,12 @@ module Spree
|
|
65
71
|
|
66
72
|
def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
|
67
73
|
parameters ||= {}
|
68
|
-
process(action, method, parameters
|
74
|
+
process(action, method, parameters, session, flash)
|
69
75
|
end
|
70
76
|
|
71
77
|
def process_spree_xhr_action(action, parameters = nil, session = nil, flash = nil, method = :get)
|
72
78
|
parameters ||= {}
|
73
79
|
parameters.reverse_merge!(:format => :json)
|
74
|
-
parameters.merge!(:use_route => :spree)
|
75
80
|
xml_http_request(method, action, parameters, session, flash)
|
76
81
|
end
|
77
82
|
end
|
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: 3.0.0.
|
4
|
+
version: 3.0.0.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.46.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.46.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: acts_as_list
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.10.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: 1.10.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: deface
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 5.0
|
131
|
+
version: 5.1.0
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 5.0
|
138
|
+
version: 5.1.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: highline
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -774,6 +774,7 @@ files:
|
|
774
774
|
- db/migrate/20150122202432_add_code_to_spree_promotion_categories.rb
|
775
775
|
- db/migrate/20150128032538_remove_environment_from_tracker.rb
|
776
776
|
- db/migrate/20150128060325_remove_spree_configurations.rb
|
777
|
+
- db/migrate/20150216173445_add_index_to_spree_stock_items_variant_id.rb
|
777
778
|
- db/seeds.rb
|
778
779
|
- lib/generators/spree/custom_user/custom_user_generator.rb
|
779
780
|
- lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
|