spree_core 2.2.13 → 2.2.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06233152b8be54206a21d59bf2e17a5d4648faed
4
- data.tar.gz: 1b924ea30f74b095be4d1e2a422398216769118e
3
+ metadata.gz: 9abfcb6e2a1a2ca7ab2c85a969e20adf636c1d99
4
+ data.tar.gz: bc242bb55726abd8ade2e39ab0c916b8f55dcc0b
5
5
  SHA512:
6
- metadata.gz: 5e0a2c71d5510cb109ef60938f3399de4c4fe15606f021252376901a59472d314c1c1f74c37dbe21919d74fabd4f47c0f126ad3c1922990df6b6edc4c3d5518c
7
- data.tar.gz: 7cac8350ffe56e20e061e346920d7dd44aa806ed6f27e8f6a9e1b5cbdf117cca3099d4dac4c97c5cbed11e3b4988987d70bd0c28e06afd829e0a45a380c8ecad
6
+ metadata.gz: 8a647ec37f24df8c6263501ef76128452751fb2afc06c5734b36fcb37732f4cbfe6bea13ae6f5ad3d4c33d1fcbe72aeb330252c8d412b9e6e816d045ec341f70
7
+ data.tar.gz: 8c39cb145273c64b9c6fc7f6f01b6222f3b6c235d151e85e2937bb217eab3861a4ec41bc7cebab3b1533eb03bfd89fe826f2096ea5df2ae93259fc3e2d2d59e4
@@ -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)
@@ -34,6 +34,9 @@ module Spree
34
34
 
35
35
  attr_accessor :target_shipment
36
36
 
37
+ self.whitelisted_ransackable_associations = ['variant']
38
+ self.whitelisted_ransackable_attributes = ['variant_id']
39
+
37
40
  def copy_price
38
41
  if variant
39
42
  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:
@@ -17,6 +17,9 @@ module Spree
17
17
 
18
18
  token_resource
19
19
 
20
+ self.whitelisted_ransackable_associations = %w[shipments user promotions bill_address ship_address line_items]
21
+ self.whitelisted_ransackable_attributes = %w[completed_at created_at email number state payment_state shipment_state total]
22
+
20
23
  attr_reader :coupon_code
21
24
 
22
25
  if Spree.user_class
@@ -11,6 +11,8 @@ module Spree
11
11
  end
12
12
  alias :display_price :display_amount
13
13
 
14
+ self.whitelisted_ransackable_attributes = ['amount']
15
+
14
16
  def money
15
17
  Spree::Money.new(amount || 0, { currency: currency })
16
18
  end
@@ -40,7 +40,7 @@ module Spree
40
40
  -> { where is_master: true },
41
41
  inverse_of: :product,
42
42
  class_name: 'Spree::Variant'
43
-
43
+
44
44
  has_many :variants,
45
45
  -> { where(is_master: false).order("#{::Spree::Variant.quoted_table_name}.position ASC") },
46
46
  inverse_of: :product,
@@ -91,6 +91,9 @@ module Spree
91
91
 
92
92
  after_initialize :ensure_master
93
93
 
94
+ self.whitelisted_ransackable_associations = %w[stores variants_including_master master variants]
95
+ self.whitelisted_ransackable_attributes = %w[slug]
96
+
94
97
  def to_param
95
98
  slug
96
99
  end
@@ -8,6 +8,8 @@ module Spree
8
8
 
9
9
  default_scope -> { order("#{self.table_name}.position") }
10
10
 
11
+ self.whitelisted_ransackable_attributes = ['value']
12
+
11
13
  # virtual attributes for use with AJAX completion stuff
12
14
  def property_name
13
15
  property.name if property
@@ -22,6 +22,8 @@ module Spree
22
22
 
23
23
  before_save :normalize_blank_values
24
24
 
25
+ self.whitelisted_ransackable_attributes = ['code', 'path', 'promotion_category_id']
26
+
25
27
  def self.advertised
26
28
  where(advertise: true)
27
29
  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
@@ -15,6 +15,8 @@ module Spree
15
15
  after_save :conditional_variant_touch, if: :changed?
16
16
  after_touch { variant.touch }
17
17
 
18
+ self.whitelisted_ransackable_attributes = ['count_on_hand', 'stock_location_id']
19
+
18
20
  def backordered_inventory_units
19
21
  Spree::InventoryUnit.backordered_for_stock_item(self)
20
22
  end
@@ -10,6 +10,8 @@ module Spree
10
10
 
11
11
  scope :recent, -> { order('created_at DESC') }
12
12
 
13
+ self.whitelisted_ransackable_attributes = ['quantity']
14
+
13
15
  def readonly?
14
16
  !new_record?
15
17
  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
@@ -46,6 +46,9 @@ module Spree
46
46
  # default variant scope only lists non-deleted variants
47
47
  scope :deleted, lambda { where.not(deleted_at: nil) }
48
48
 
49
+ self.whitelisted_ransackable_associations = %w[option_values product prices default_price]
50
+ self.whitelisted_ransackable_attributes = %w[weight sku]
51
+
49
52
  def self.active(currency = nil)
50
53
  joins(:prices).where(deleted_at: nil).where('spree_prices.currency' => currency || Spree::Config[:currency]).where('spree_prices.amount IS NOT NULL')
51
54
  end
@@ -12,6 +12,8 @@ module Spree
12
12
  alias :members :zone_members
13
13
  accepts_nested_attributes_for :zone_members, allow_destroy: true, reject_if: proc { |a| a['zoneable_id'].blank? }
14
14
 
15
+ self.whitelisted_ransackable_attributes = ['description']
16
+
15
17
  def self.default_tax
16
18
  where(default_tax: true).first
17
19
  end
@@ -14,6 +14,14 @@ Spree::Core::Engine.config.to_prepare do
14
14
  belongs_to :ship_address, :class_name => 'Spree::Address'
15
15
  belongs_to :bill_address, :class_name => 'Spree::Address'
16
16
 
17
+ def self.ransackable_associations(auth_object=nil)
18
+ %w[bill_address ship_address]
19
+ end
20
+
21
+ def self.ransackable_attributes(auth_object=nil)
22
+ %w[id email]
23
+ end
24
+
17
25
  # has_spree_role? simply needs to return true or false whether a user has a role or not.
18
26
  def has_spree_role?(role_in_question)
19
27
  spree_roles.where(:name => role_in_question.to_s).any?
data/lib/spree/core.rb CHANGED
@@ -49,6 +49,7 @@ end
49
49
 
50
50
  require 'spree/core/version'
51
51
 
52
+ require 'spree/core/ransackable_attributes'
52
53
  require 'spree/core/mail_interceptor'
53
54
  require 'spree/core/mail_method'
54
55
  require 'spree/core/mail_settings'
@@ -0,0 +1,15 @@
1
+ ActiveRecord::Base.class_eval do
2
+ class_attribute :whitelisted_ransackable_associations
3
+ class_attribute :whitelisted_ransackable_attributes
4
+
5
+ class_attribute :default_ransackable_attributes
6
+ self.default_ransackable_attributes = %w[id name]
7
+
8
+ def self.ransackable_associations *arg
9
+ self.whitelisted_ransackable_associations || []
10
+ end
11
+
12
+ def self.ransackable_attributes *arg
13
+ self.default_ransackable_attributes | (self.whitelisted_ransackable_attributes || [])
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Spree
2
2
  def self.version
3
- '2.2.13'
3
+ '2.2.14'
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.2.13
4
+ version: 2.2.14
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
@@ -653,6 +653,7 @@ files:
653
653
  - lib/spree/core/permalinks.rb
654
654
  - lib/spree/core/product_duplicator.rb
655
655
  - lib/spree/core/product_filters.rb
656
+ - lib/spree/core/ransackable_attributes.rb
656
657
  - lib/spree/core/routes.rb
657
658
  - lib/spree/core/search/base.rb
658
659
  - lib/spree/core/token_resource.rb