spree_core 2.4.9 → 2.4.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a521e65bfd71b442a333dda2b8a985f260271bb5
4
- data.tar.gz: 74ef210d20467f665bf8291f0809faa233dd35ad
3
+ metadata.gz: 920d1116f3ab6e3411d25cbb20a68d9a3219dc54
4
+ data.tar.gz: 5ce011d689d7dc2c8b5daa7af24fa35cda922a75
5
5
  SHA512:
6
- metadata.gz: 2869743bc9699dcf28957325fd4ad920e78291c727159365572f370dab947a2a9079ff07b3274726687ae07c00e4dc0e32d1de2baaa0825b63a7bcc727f8f207
7
- data.tar.gz: 826b25d6ed1d4261afd38c27f50b9a3d98443199a17d64edfa6d421ea169af2b6a8c94d226dc0de5f59e4e6d993c7892e8643df9355b7f52ee7f060c56a5d8a4
6
+ metadata.gz: 1904b47e5b0daea447eac9c638e2ea0b781758ed32e8f8e30f07e361bfa1e8bfbdce55d100f2678043d6bbe80a2ef3a130628d5b619790d615d6cd1830108392
7
+ data.tar.gz: bcad22a5914ca2dfc426588ec7ccaaefe6169801d4f8b3e0366e3f71b517e1042e84a60d819bd0eed13d39b76ca435c93359fc1dafa854c05f9303e0832ed227
@@ -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
@@ -16,6 +16,8 @@ module Spree
16
16
  alias_attribute :first_name, :firstname
17
17
  alias_attribute :last_name, :lastname
18
18
 
19
+ self.whitelisted_ransackable_attributes = %w[firstname lastname]
20
+
19
21
  def self.build_default
20
22
  country = Spree::Country.find(Spree::Config[:default_country_id]) rescue Spree::Country.first
21
23
  new(country: country)
@@ -36,7 +36,7 @@ module Spree
36
36
  preference :auto_capture, :boolean, default: false # automatically capture the credit card (as opposed to just authorize and capture later)
37
37
  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.
38
38
  preference :binary_inventory_cache, :boolean, default: false # only invalidate product cache when a stock item changes whether it is in_stock
39
- preference :check_for_spree_alerts, :boolean, default: true
39
+ preference :check_for_spree_alerts, :boolean, default: false
40
40
  preference :checkout_zone, :string, default: nil # replace with the name of a zone if you would like to limit the countries
41
41
  preference :company, :boolean, default: false # Request company field for billing and shipping addr
42
42
  preference :currency, :string, default: "USD"
@@ -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
@@ -35,6 +35,9 @@ module Spree
35
35
 
36
36
  attr_accessor :target_shipment
37
37
 
38
+ self.whitelisted_ransackable_associations = ['variant']
39
+ self.whitelisted_ransackable_attributes = ['variant_id']
40
+
38
41
  def copy_price
39
42
  if variant
40
43
  self.price = variant.price if price.nil?
@@ -9,6 +9,8 @@ module Spree
9
9
 
10
10
  after_touch :touch_all_variants
11
11
 
12
+ self.whitelisted_ransackable_attributes = ['presentation']
13
+
12
14
  def touch_all_variants
13
15
  variants.update_all(updated_at: Time.current)
14
16
  end
@@ -21,6 +21,9 @@ module Spree
21
21
  remove_transition from: :delivery, to: :confirm
22
22
  end
23
23
 
24
+ self.whitelisted_ransackable_associations = %w[shipments user promotions bill_address ship_address line_items]
25
+ self.whitelisted_ransackable_attributes = %w[completed_at created_at email number state payment_state shipment_state total considered_risky]
26
+
24
27
  attr_reader :coupon_code
25
28
  attr_accessor :temporary_address, :temporary_credit_card
26
29
 
@@ -12,6 +12,8 @@ module Spree
12
12
  end
13
13
  alias :display_price :display_amount
14
14
 
15
+ self.whitelisted_ransackable_attributes = ['amount']
16
+
15
17
  def money
16
18
  Spree::Money.new(amount || 0, { currency: currency })
17
19
  end
@@ -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?
@@ -11,6 +11,8 @@ module Spree
11
11
 
12
12
  default_scope -> { order("#{self.table_name}.position") }
13
13
 
14
+ self.whitelisted_ransackable_attributes = ['value']
15
+
14
16
  # virtual attributes for use with AJAX completion stuff
15
17
  def property_name
16
18
  property.name if property
@@ -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
@@ -11,6 +11,8 @@ module Spree
11
11
 
12
12
  after_touch :touch_all_products
13
13
 
14
+ self.whitelisted_ransackable_attributes = ['presentation']
15
+
14
16
  private
15
17
 
16
18
  def touch_all_products
@@ -83,9 +83,9 @@ module Spree
83
83
  end
84
84
 
85
85
  def calculated_total
86
- # rounding down to handle edge cases for consecutive partial returns where rounding
87
- # might cause us to try to reimburse more than was originally billed
88
- return_items.to_a.sum(&:total).to_d.round(2, :down)
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.sum(&:total).round(2, :down)
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.sum(&:total).round(2, :down)
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)
@@ -34,6 +34,8 @@ module Spree
34
34
 
35
35
  end
36
36
 
37
+ self.whitelisted_ransackable_attributes = ['memo']
38
+
37
39
  def pre_tax_total
38
40
  return_items.sum(:pre_tax_amount)
39
41
  end
@@ -76,6 +76,8 @@ module Spree
76
76
  end
77
77
  end
78
78
 
79
+ self.whitelisted_ransackable_attributes = ['number']
80
+
79
81
  def add_shipping_method(shipping_method, selected = false)
80
82
  shipping_rates.create(shipping_method: shipping_method, selected: selected, cost: cost)
81
83
  end
@@ -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
 
16
16
  scope :recent, -> { order('created_at DESC') }
17
17
 
18
+ self.whitelisted_ransackable_attributes = ['quantity']
19
+
18
20
  def readonly?
19
21
  !new_record?
20
22
  end
@@ -7,6 +7,8 @@ module Spree
7
7
 
8
8
  make_permalink field: :number, prefix: 'T'
9
9
 
10
+ self.whitelisted_ransackable_attributes = %w[reference source_location_id destination_location_id closed_at created_at number]
11
+
10
12
  def to_param
11
13
  number
12
14
  end
@@ -43,6 +43,9 @@ module Spree
43
43
 
44
44
  scope :in_stock, -> { joins(:stock_items).where('count_on_hand > ? OR track_inventory = ?', 0, false) }
45
45
 
46
+ self.whitelisted_ransackable_associations = %w[option_values product prices default_price]
47
+ self.whitelisted_ransackable_attributes = %w[weight sku]
48
+
46
49
  def self.active(currency = nil)
47
50
  joins(:prices).where(deleted_at: nil).where('spree_prices.currency' => currency || Spree::Config[:currency]).where('spree_prices.amount IS NOT NULL')
48
51
  end
@@ -11,6 +11,8 @@ module Spree
11
11
  alias :members :zone_members
12
12
  accepts_nested_attributes_for :zone_members, allow_destroy: true, reject_if: proc { |a| a['zoneable_id'].blank? }
13
13
 
14
+ self.whitelisted_ransackable_attributes = ['description']
15
+
14
16
  def self.default_tax
15
17
  where(default_tax: true).first
16
18
  end
@@ -15,6 +15,14 @@ Spree::Core::Engine.config.to_prepare do
15
15
  belongs_to :ship_address, class_name: 'Spree::Address'
16
16
  belongs_to :bill_address, class_name: 'Spree::Address'
17
17
 
18
+ def self.ransackable_associations(auth_object=nil)
19
+ %w[bill_address ship_address]
20
+ end
21
+
22
+ def self.ransackable_attributes(auth_object=nil)
23
+ %w[id email]
24
+ end
25
+
18
26
  # has_spree_role? simply needs to return true or false whether a user has a role or not.
19
27
  def has_spree_role?(role_in_question)
20
28
  spree_roles.where(name: role_in_question.to_s).any?
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- '2.4.9'
3
+ '2.4.10'
4
4
  end
5
5
  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: 2.4.9
4
+ version: 2.4.10
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-07-28 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -381,6 +381,7 @@ files:
381
381
  - app/models/concerns/spree/calculated_adjustments.rb
382
382
  - app/models/concerns/spree/default_price.rb
383
383
  - app/models/concerns/spree/named_type.rb
384
+ - app/models/concerns/spree/ransackable_attributes.rb
384
385
  - app/models/concerns/spree/user_address.rb
385
386
  - app/models/concerns/spree/user_api_authentication.rb
386
387
  - app/models/concerns/spree/user_payment_source.rb