solidus_core 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_core might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50bd29de10c7232c6a5dce938b456b7e50b272f0
4
- data.tar.gz: b0def8e0cf515c431e8ce61d81b1cb19d5853d76
3
+ metadata.gz: e4c9d8f7e575ee2b1f7282a63b107a3526650269
4
+ data.tar.gz: ecaa9e9bb8ec49d159675e49f2bbea138fbfe0de
5
5
  SHA512:
6
- metadata.gz: 30a7433f3c995f231a8ecfca3196b6798229242c5684563deed7aa3ca8b942ead7307802c448da218168089e82d0d9fd87b307a947f9e428c1be0e8d62f12e8f
7
- data.tar.gz: e99212264483a442793e58b83010a2e8169a21af85ae8f90d02233e35991206ee11517fa77299e3d43690aff0ce810f2cc26cdc39fd1034afe30721c8e9bd461
6
+ metadata.gz: badb4d1790e571121a237cb462bc9fae924a0793e6d16cdd169d3cb427dcb4f725a2c610602de02a678af6fcd5d2fa4632635abbf50af741a6c54263b70ea838
7
+ data.tar.gz: 7165bf3a4b9ab49278310e03711d555b7434f5afa15311eba73afce655e3b6d3b3eba7076443a0af98f2aac2ee3192647b240d362326bfa4bcd3cbd8aaef8b77
@@ -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
@@ -25,6 +25,14 @@ module Spree
25
25
 
26
26
  belongs_to :ship_address, class_name: 'Spree::Address'
27
27
  belongs_to :bill_address, class_name: 'Spree::Address'
28
+
29
+ def self.ransackable_associations(auth_object=nil)
30
+ %w[bill_address ship_address]
31
+ end
32
+
33
+ def self.ransackable_attributes(auth_object=nil)
34
+ %w[id email]
35
+ end
28
36
  end
29
37
 
30
38
  # has_spree_role? simply needs to return true or false whether a user has a role or not.
@@ -18,6 +18,9 @@ module Spree
18
18
  alias_attribute :first_name, :firstname
19
19
  alias_attribute :last_name, :lastname
20
20
 
21
+
22
+ self.whitelisted_ransackable_attributes = %w[firstname lastname]
23
+
21
24
  def self.build_default
22
25
  country = Spree::Country.find(Spree::Config[:default_country_id]) rescue Spree::Country.first
23
26
  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
  if has_attribute?(:preferences)
6
9
  self.preferences = default_preferences.merge(preferences)
@@ -37,6 +37,9 @@ module Spree
37
37
 
38
38
  attr_accessor :target_shipment
39
39
 
40
+ self.whitelisted_ransackable_associations = ['variant']
41
+ self.whitelisted_ransackable_attributes = ['variant_id']
42
+
40
43
  # Sets this line item's price, cost price, and currency from this line
41
44
  # item's variant if they are nil and a variant is present.
42
45
  def copy_price
@@ -12,6 +12,8 @@ module Spree
12
12
  after_save :touch
13
13
  after_touch :touch_all_variants
14
14
 
15
+ self.whitelisted_ransackable_attributes = ['presentation']
16
+
15
17
  # Updates the updated_at column on all the variants associated with this
16
18
  # option value.
17
19
  def touch_all_variants
@@ -28,6 +28,9 @@ module Spree
28
28
  go_to_state :confirm
29
29
  end
30
30
 
31
+ self.whitelisted_ransackable_associations = %w[shipments user promotions bill_address ship_address line_items]
32
+ self.whitelisted_ransackable_attributes = %w[completed_at created_at email number state payment_state shipment_state total]
33
+
31
34
  attr_reader :coupon_code
32
35
  attr_accessor :temporary_address, :temporary_credit_card
33
36
 
@@ -2,6 +2,7 @@ module Spree
2
2
  module PermissionSets
3
3
  class OrderManagement < PermissionSets::Base
4
4
  def activate!
5
+ can :display, Spree::ReimbursementType
5
6
  can :manage, Spree::Order
6
7
  can :manage, Spree::Payment
7
8
  can :manage, Spree::Shipment
@@ -9,6 +10,7 @@ module Spree
9
10
  can :manage, Spree::LineItem
10
11
  can :manage, Spree::ReturnAuthorization
11
12
  can :manage, Spree::CustomerReturn
13
+ can :manage, Spree::OrderCancellations
12
14
  end
13
15
  end
14
16
  end
@@ -11,6 +11,8 @@ module Spree
11
11
  extend DisplayMoney
12
12
  money_methods :amount, :price
13
13
 
14
+ self.whitelisted_ransackable_attributes = ['amount']
15
+
14
16
  # @return [Spree::Money] this price as a Spree::Money object
15
17
  def money
16
18
  Spree::Money.new(amount || 0, { currency: currency })
@@ -86,6 +86,9 @@ module Spree
86
86
 
87
87
  alias :options :product_option_types
88
88
 
89
+ self.whitelisted_ransackable_associations = %w[stores variants_including_master master variants]
90
+ self.whitelisted_ransackable_attributes = %w[slug]
91
+
89
92
  # @return [Boolean] true if there are any variants
90
93
  def has_variants?
91
94
  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
@@ -41,6 +41,9 @@ module Spree
41
41
  end
42
42
  scope :applied, -> { joins(:order_promotions).uniq }
43
43
 
44
+ self.whitelisted_ransackable_associations = ['codes']
45
+ self.whitelisted_ransackable_attributes = ['path', 'promotion_category_id']
46
+
44
47
  # temporary code. remove after the column is dropped from the db.
45
48
  def columns
46
49
  super.reject { |column| column.name == "code" }
@@ -1,4 +1,4 @@
1
- class Spree::PromotionCode < ActiveRecord::Base
1
+ class Spree::PromotionCode < Spree::Base
2
2
  belongs_to :promotion, inverse_of: :codes
3
3
  has_many :adjustments
4
4
 
@@ -7,6 +7,8 @@ class Spree::PromotionCode < ActiveRecord::Base
7
7
 
8
8
  before_save :downcase_value
9
9
 
10
+ self.whitelisted_ransackable_attributes = ['value']
11
+
10
12
  # Whether the promotion code has exceeded its usage restrictions
11
13
  #
12
14
  # @return true or false
@@ -38,6 +38,8 @@ module Spree
38
38
  extend DisplayMoney
39
39
  money_methods :pre_tax_total
40
40
 
41
+ self.whitelisted_ransackable_attributes = ['memo']
42
+
41
43
  def pre_tax_total
42
44
  return_items.sum(:pre_tax_amount)
43
45
  end
@@ -72,6 +72,8 @@ module Spree
72
72
  end
73
73
  end
74
74
 
75
+ self.whitelisted_ransackable_attributes = ['number']
76
+
75
77
  def can_transition_from_pending_to_shipped?
76
78
  !requires_shipment?
77
79
  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
  # @return [Array<Spree::InventoryUnit>] the backordered inventory units
19
21
  # associated with this stock item
20
22
  def backordered_inventory_units
@@ -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,9 +7,9 @@ module Spree
7
7
  has_many :stock_movements, :as => :originator
8
8
  has_many :transfer_items, inverse_of: :stock_transfer
9
9
 
10
- belongs_to :created_by, :class_name => Spree.user_class.to_s
11
- belongs_to :finalized_by, :class_name => Spree.user_class.to_s
12
- belongs_to :closed_by, :class_name => Spree.user_class.to_s
10
+ belongs_to :created_by, :class_name => Spree::UserClassHandle.new
11
+ belongs_to :finalized_by, :class_name => Spree::UserClassHandle.new
12
+ belongs_to :closed_by, :class_name => Spree::UserClassHandle.new
13
13
  belongs_to :source_location, :class_name => 'Spree::StockLocation'
14
14
  belongs_to :destination_location, :class_name => 'Spree::StockLocation'
15
15
 
@@ -20,6 +20,8 @@ module Spree
20
20
 
21
21
  before_destroy :ensure_not_finalized
22
22
 
23
+ self.whitelisted_ransackable_attributes = %w[source_location_id destination_location_id closed_at created_at number]
24
+
23
25
  def to_param
24
26
  number
25
27
  end
@@ -66,6 +66,9 @@ module Spree
66
66
 
67
67
  scope :in_stock, -> { joins(:stock_items).where('count_on_hand > ? OR track_inventory = ?', 0, false) }
68
68
 
69
+ self.whitelisted_ransackable_associations = %w[option_values product prices default_price]
70
+ self.whitelisted_ransackable_attributes = %w[weight sku]
71
+
69
72
  # Returns variants that are not deleted and have a price in the given
70
73
  # currency.
71
74
  #
@@ -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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-11 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
@@ -382,6 +382,7 @@ files:
382
382
  - app/models/concerns/spree/default_price.rb
383
383
  - app/models/concerns/spree/display_money.rb
384
384
  - app/models/concerns/spree/named_type.rb
385
+ - app/models/concerns/spree/ransackable_attributes.rb
385
386
  - app/models/concerns/spree/user_address.rb
386
387
  - app/models/concerns/spree/user_api_authentication.rb
387
388
  - app/models/concerns/spree/user_methods.rb