spree_core 3.0.3 → 3.0.4
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/ransackable_attributes.rb +19 -0
- data/app/models/spree/address.rb +3 -0
- data/app/models/spree/app_configuration.rb +1 -1
- data/app/models/spree/base.rb +3 -0
- data/app/models/spree/line_item.rb +3 -0
- data/app/models/spree/option_value.rb +2 -0
- data/app/models/spree/order.rb +3 -0
- data/app/models/spree/price.rb +2 -0
- data/app/models/spree/product.rb +3 -0
- data/app/models/spree/product_property.rb +2 -0
- data/app/models/spree/promotion.rb +2 -0
- data/app/models/spree/property.rb +2 -0
- data/app/models/spree/reimbursement.rb +3 -3
- data/app/models/spree/reimbursement_type/credit.rb +1 -1
- data/app/models/spree/reimbursement_type/original_payment.rb +1 -1
- data/app/models/spree/return_authorization.rb +2 -0
- data/app/models/spree/shipment.rb +2 -0
- data/app/models/spree/stock_item.rb +2 -0
- data/app/models/spree/stock_movement.rb +2 -0
- data/app/models/spree/stock_transfer.rb +2 -0
- data/app/models/spree/variant.rb +3 -0
- data/app/models/spree/zone.rb +2 -0
- data/config/initializers/user_class_extensions.rb +8 -0
- data/lib/spree/core/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 825167ffd3b796e7bd880c79751eeb2631f9762e
|
4
|
+
data.tar.gz: 3dfd8c5d5a0301435c90967be33a2befc3950087
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9935e7fc716719657036cfb862d4a6ac5a705303c0029ca2828948ababadb82b97ea92d3a8e2580fc3a8c2df0a962b7920035ef7aec47bc81bd3bbc3d65b206b
|
7
|
+
data.tar.gz: 65ef7e2171aecf3e4a62c863601959e550bfad2d8c0e80ac7314469a13adc2dbdb079b6dc48ba02acf8e412da7aed44124c06d073dcfeeec67f0b79d071e13ef
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spree::RansackableAttributes
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
included do
|
4
|
+
class_attribute :whitelisted_ransackable_associations
|
5
|
+
class_attribute :whitelisted_ransackable_attributes
|
6
|
+
|
7
|
+
class_attribute :default_ransackable_attributes
|
8
|
+
self.default_ransackable_attributes = %w[id name]
|
9
|
+
|
10
|
+
def self.ransackable_associations(*args)
|
11
|
+
self.whitelisted_ransackable_associations || []
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.ransackable_attributes(*args)
|
15
|
+
self.default_ransackable_attributes | (self.whitelisted_ransackable_attributes || [])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/app/models/spree/address.rb
CHANGED
@@ -16,6 +16,9 @@ module Spree
|
|
16
16
|
alias_attribute :first_name, :firstname
|
17
17
|
alias_attribute :last_name, :lastname
|
18
18
|
|
19
|
+
|
20
|
+
self.whitelisted_ransackable_attributes = %w[firstname lastname company]
|
21
|
+
|
19
22
|
def self.build_default
|
20
23
|
country = Spree::Country.find(Spree::Config[:default_country_id]) rescue Spree::Country.first
|
21
24
|
new(country: country)
|
@@ -31,7 +31,7 @@ module Spree
|
|
31
31
|
preference :auto_capture, :boolean, default: false # automatically capture the credit card (as opposed to just authorize and capture later)
|
32
32
|
preference :auto_capture_on_dispatch, :boolean, default: false # Captures payment for each shipment in Shipment#after_ship callback, and makes Shipment.ready when payment authorized.
|
33
33
|
preference :binary_inventory_cache, :boolean, default: false # only invalidate product cache when a stock item changes whether it is in_stock
|
34
|
-
preference :check_for_spree_alerts, :boolean, default:
|
34
|
+
preference :check_for_spree_alerts, :boolean, default: false
|
35
35
|
preference :checkout_zone, :string, default: nil # replace with the name of a zone if you would like to limit the countries
|
36
36
|
preference :company, :boolean, default: false # Request company field for billing and shipping addr
|
37
37
|
preference :currency, :string, default: "USD"
|
data/app/models/spree/base.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
class Spree::Base < ActiveRecord::Base
|
2
2
|
include Spree::Preferences::Preferable
|
3
3
|
serialize :preferences, Hash
|
4
|
+
|
5
|
+
include Spree::RansackableAttributes
|
6
|
+
|
4
7
|
after_initialize do
|
5
8
|
self.preferences = default_preferences.merge(preferences) if has_attribute?(:preferences)
|
6
9
|
end
|
data/app/models/spree/order.rb
CHANGED
@@ -36,6 +36,9 @@ module Spree
|
|
36
36
|
remove_transition from: :delivery, to: :confirm
|
37
37
|
end
|
38
38
|
|
39
|
+
self.whitelisted_ransackable_associations = %w[shipments user promotions bill_address ship_address line_items]
|
40
|
+
self.whitelisted_ransackable_attributes = %w[completed_at created_at email number state payment_state shipment_state total considered_risky]
|
41
|
+
|
39
42
|
attr_reader :coupon_code
|
40
43
|
attr_accessor :temporary_address, :temporary_credit_card
|
41
44
|
|
data/app/models/spree/price.rb
CHANGED
data/app/models/spree/product.rb
CHANGED
@@ -99,6 +99,9 @@ module Spree
|
|
99
99
|
|
100
100
|
alias :options :product_option_types
|
101
101
|
|
102
|
+
self.whitelisted_ransackable_associations = %w[stores variants_including_master master variants]
|
103
|
+
self.whitelisted_ransackable_attributes = %w[slug]
|
104
|
+
|
102
105
|
# the master variant is not a member of the variants array
|
103
106
|
def has_variants?
|
104
107
|
variants.any?
|
@@ -32,6 +32,8 @@ module Spree
|
|
32
32
|
|
33
33
|
scope :applied, -> { joins("INNER JOIN #{order_join_table} ON #{order_join_table}.promotion_id = #{table_name}.id").uniq }
|
34
34
|
|
35
|
+
self.whitelisted_ransackable_attributes = ['code', 'path', 'promotion_category_id']
|
36
|
+
|
35
37
|
def self.advertised
|
36
38
|
where(advertise: true)
|
37
39
|
end
|
@@ -83,9 +83,9 @@ module Spree
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def calculated_total
|
86
|
-
# rounding
|
87
|
-
# might cause us to try to reimburse more than was originally billed
|
88
|
-
return_items.
|
86
|
+
# rounding every return item individually to handle edge cases for consecutive partial
|
87
|
+
# returns where rounding might cause us to try to reimburse more than was originally billed
|
88
|
+
return_items.map { |ri| ri.total.to_d.round(2) }.sum
|
89
89
|
end
|
90
90
|
|
91
91
|
def paid_amount
|
@@ -4,7 +4,7 @@ module Spree
|
|
4
4
|
|
5
5
|
class << self
|
6
6
|
def reimburse(reimbursement, return_items, simulate)
|
7
|
-
unpaid_amount = return_items.
|
7
|
+
unpaid_amount = return_items.map { |ri| ri.total.to_d.round(2) }.sum
|
8
8
|
reimbursement_list, unpaid_amount = create_credits(reimbursement, unpaid_amount, simulate)
|
9
9
|
reimbursement_list
|
10
10
|
end
|
@@ -3,7 +3,7 @@ class Spree::ReimbursementType::OriginalPayment < Spree::ReimbursementType
|
|
3
3
|
|
4
4
|
class << self
|
5
5
|
def reimburse(reimbursement, return_items, simulate)
|
6
|
-
unpaid_amount = return_items.
|
6
|
+
unpaid_amount = return_items.map { |ri| ri.total.to_d.round(2) }.sum
|
7
7
|
payments = reimbursement.order.payments.completed
|
8
8
|
|
9
9
|
refund_list, unpaid_amount = create_refunds(reimbursement, payments, unpaid_amount, simulate)
|
@@ -19,6 +19,8 @@ module Spree
|
|
19
19
|
after_save :conditional_variant_touch, if: :changed?
|
20
20
|
after_touch { variant.touch }
|
21
21
|
|
22
|
+
self.whitelisted_ransackable_attributes = ['count_on_hand', 'stock_location_id']
|
23
|
+
|
22
24
|
def backordered_inventory_units
|
23
25
|
Spree::InventoryUnit.backordered_for_stock_item(self)
|
24
26
|
end
|
@@ -15,6 +15,8 @@ module Spree
|
|
15
15
|
belongs_to :source_location, class_name: 'StockLocation'
|
16
16
|
belongs_to :destination_location, class_name: 'StockLocation'
|
17
17
|
|
18
|
+
self.whitelisted_ransackable_attributes = %w[reference source_location_id destination_location_id closed_at created_at number]
|
19
|
+
|
18
20
|
def to_param
|
19
21
|
number
|
20
22
|
end
|
data/app/models/spree/variant.rb
CHANGED
@@ -51,6 +51,9 @@ module Spree
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
self.whitelisted_ransackable_associations = %w[option_values product prices default_price]
|
55
|
+
self.whitelisted_ransackable_attributes = %w[weight sku]
|
56
|
+
|
54
57
|
def self.active(currency = nil)
|
55
58
|
joins(:prices).where(deleted_at: nil).where('spree_prices.currency' => currency || Spree::Config[:currency]).where('spree_prices.amount IS NOT NULL')
|
56
59
|
end
|
data/app/models/spree/zone.rb
CHANGED
@@ -15,6 +15,8 @@ module Spree
|
|
15
15
|
alias :members :zone_members
|
16
16
|
accepts_nested_attributes_for :zone_members, allow_destroy: true, reject_if: proc { |a| a['zoneable_id'].blank? }
|
17
17
|
|
18
|
+
self.whitelisted_ransackable_attributes = ['description']
|
19
|
+
|
18
20
|
def self.default_tax
|
19
21
|
where(default_tax: true).first
|
20
22
|
end
|
@@ -16,6 +16,14 @@ Spree::Core::Engine.config.to_prepare do
|
|
16
16
|
belongs_to :ship_address, class_name: 'Spree::Address'
|
17
17
|
belongs_to :bill_address, class_name: 'Spree::Address'
|
18
18
|
|
19
|
+
def self.ransackable_associations(auth_object=nil)
|
20
|
+
%w[bill_address ship_address]
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.ransackable_attributes(auth_object=nil)
|
24
|
+
%w[id email]
|
25
|
+
end
|
26
|
+
|
19
27
|
# has_spree_role? simply needs to return true or false whether a user has a role or not.
|
20
28
|
def has_spree_role?(role_in_question)
|
21
29
|
spree_roles.where(name: role_in_question.to_s).any?
|
data/lib/spree/core/version.rb
CHANGED
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.
|
4
|
+
version: 3.0.4
|
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-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -393,6 +393,7 @@ files:
|
|
393
393
|
- app/models/concerns/spree/display_money.rb
|
394
394
|
- app/models/concerns/spree/named_type.rb
|
395
395
|
- app/models/concerns/spree/number_generator.rb
|
396
|
+
- app/models/concerns/spree/ransackable_attributes.rb
|
396
397
|
- app/models/concerns/spree/user_address.rb
|
397
398
|
- app/models/concerns/spree/user_api_authentication.rb
|
398
399
|
- app/models/concerns/spree/user_payment_source.rb
|