spree_core 2.3.12 → 2.3.13

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: 65ea4c6536760142878867963831fef1329d7df0
4
- data.tar.gz: e12480669bff9bbc377cc0dd6e8a217691372748
3
+ metadata.gz: 01725f9ca0e549175b6eff9da2061ad94f0e24c6
4
+ data.tar.gz: 812d8b5e508a5ccbd8e0a53728335a5d43a25b30
5
5
  SHA512:
6
- metadata.gz: de264bbcb4b2ea76676cd1375181762ee9005b2501d5ed5683abba07bd502131ea5fe96bb72c21854feff74e8835d0034d2da96549c0463d3a1c9603bb926802
7
- data.tar.gz: 388c0871a6518c6f045ed376d1b8121204cb8cf3a07b70a4f6761fe9e0311e9daa68ef1d4dc37677325dd59ba766fc67b6d63f3e7eb3b25100e0251d6f6f35ef
6
+ metadata.gz: a56c3a3d6b44d2b584668fbeebace2bcb389d2962a8959345fa84f676b315417eeedf61b56152e6a3b42ede1c0173efcb401715a5c244d0c99a27370cf93aa34
7
+ data.tar.gz: 0c4f145ce06584f368f388c3c7a1825a7f5458109abb68ba2c297b748428b7ff04e897568deb072fb55ccfaee5a3fa6e7badf6eda55014dd3a69fdeac0480ea2
@@ -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
@@ -14,6 +14,9 @@ module Spree
14
14
  alias_attribute :first_name, :firstname
15
15
  alias_attribute :last_name, :lastname
16
16
 
17
+
18
+ self.whitelisted_ransackable_attributes = %w[firstname lastname]
19
+
17
20
  def self.build_default
18
21
  country = Spree::Country.find(Spree::Config[:default_country_id]) rescue Spree::Country.first
19
22
  new(country: country)
@@ -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?
@@ -8,6 +8,8 @@ module Spree
8
8
 
9
9
  after_touch :touch_all_variants
10
10
 
11
+ self.whitelisted_ransackable_attributes = ['presentation']
12
+
11
13
  def touch_all_variants
12
14
  # This can cause a cascade of products to be updated
13
15
  # To disable it in Rails 4.1, we can do this:
@@ -15,6 +15,9 @@ module Spree
15
15
  remove_transition from: :delivery, to: :confirm
16
16
  end
17
17
 
18
+ self.whitelisted_ransackable_associations = %w[shipments user promotions bill_address ship_address line_items]
19
+ self.whitelisted_ransackable_attributes = %w[completed_at created_at email number state payment_state shipment_state total considered_risky]
20
+
18
21
  attr_reader :coupon_code
19
22
  attr_accessor :temporary_address
20
23
 
@@ -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
@@ -97,6 +97,9 @@ module Spree
97
97
 
98
98
  alias :options :product_option_types
99
99
 
100
+ self.whitelisted_ransackable_associations = %w[stores variants_including_master master variants]
101
+ self.whitelisted_ransackable_attributes = %w[slug]
102
+
100
103
  # the master variant is not a member of the variants array
101
104
  def has_variants?
102
105
  variants.any?
@@ -9,6 +9,8 @@ module Spree
9
9
 
10
10
  default_scope -> { order("#{self.table_name}.position") }
11
11
 
12
+ self.whitelisted_ransackable_attributes = ['value']
13
+
12
14
  # virtual attributes for use with AJAX completion stuff
13
15
  def property_name
14
16
  property.name if property
@@ -25,6 +25,8 @@ module Spree
25
25
  scope :coupons, ->{ where("#{table_name}.code IS NOT NULL") }
26
26
  scope :applied, -> { joins(:orders).uniq }
27
27
 
28
+ self.whitelisted_ransackable_attributes = ['code', 'path', 'promotion_category_id']
29
+
28
30
  def self.advertised
29
31
  where(advertise: true)
30
32
  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
  def self.find_all_by_prototype(prototype)
15
17
  id = prototype
16
18
  id = prototype.id if prototype.class == Prototype
@@ -22,6 +22,12 @@ module Spree
22
22
  end
23
23
  end
24
24
 
25
+ self.whitelisted_ransackable_attributes = ['reason']
26
+
27
+ def pre_tax_total
28
+ return_items.sum(:pre_tax_amount)
29
+ end
30
+
25
31
  def currency
26
32
  order.nil? ? Spree::Config[:currency] : order.currency
27
33
  end
@@ -93,6 +93,8 @@ module Spree
93
93
  selected_shipping_rate.try(:shipping_method) || shipping_rates.first.try(:shipping_method)
94
94
  end
95
95
 
96
+ self.whitelisted_ransackable_attributes = ['number']
97
+
96
98
  def add_shipping_method(shipping_method, selected = false)
97
99
  shipping_rates.create(shipping_method: shipping_method, selected: selected, cost: cost)
98
100
  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
@@ -49,6 +49,9 @@ module Spree
49
49
 
50
50
  after_touch :clear_in_stock_cache
51
51
 
52
+ self.whitelisted_ransackable_associations = %w[option_values product prices default_price]
53
+ self.whitelisted_ransackable_attributes = %w[weight sku]
54
+
52
55
  def self.active(currency = nil)
53
56
  joins(:prices).where(deleted_at: nil).where('spree_prices.currency' => currency || Spree::Config[:currency]).where('spree_prices.amount IS NOT NULL')
54
57
  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.3.12'
3
+ '2.3.13'
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.3.12
4
+ version: 2.3.13
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
@@ -334,6 +334,7 @@ files:
334
334
  - app/mailers/spree/order_mailer.rb
335
335
  - app/mailers/spree/shipment_mailer.rb
336
336
  - app/mailers/spree/test_mailer.rb
337
+ - app/models/concerns/spree/ransackable_attributes.rb
337
338
  - app/models/concerns/spree/user_api_authentication.rb
338
339
  - app/models/concerns/spree/user_reporting.rb
339
340
  - app/models/spree/ability.rb