solidus_core 4.4.2 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/spree/core/controller_helpers/auth.rb +66 -0
- data/app/helpers/spree/core/controller_helpers/common.rb +82 -0
- data/app/helpers/spree/core/controller_helpers/order.rb +86 -0
- data/app/helpers/spree/core/controller_helpers/payment_parameters.rb +165 -0
- data/app/helpers/spree/core/controller_helpers/pricing.rb +19 -0
- data/app/helpers/spree/core/controller_helpers/search.rb +16 -0
- data/app/helpers/spree/core/controller_helpers/store.rb +19 -0
- data/app/helpers/spree/core/controller_helpers/strong_parameters.rb +74 -0
- data/app/models/concerns/spree/metadata.rb +64 -0
- data/app/models/concerns/spree/user_address_book.rb +4 -5
- data/app/models/spree/core/state_machines/inventory_unit.rb +42 -0
- data/app/models/spree/core/state_machines/order/class_methods.rb +217 -0
- data/app/models/spree/core/state_machines/order.rb +42 -0
- data/app/models/spree/core/state_machines/payment.rb +61 -0
- data/app/models/spree/core/state_machines/reimbursement.rb +33 -0
- data/app/models/spree/core/state_machines/return_authorization.rb +32 -0
- data/app/models/spree/core/state_machines/return_item/acceptance_status.rb +51 -0
- data/app/models/spree/core/state_machines/return_item/reception_status.rb +42 -0
- data/app/models/spree/core/state_machines/shipment.rb +58 -0
- data/app/models/spree/customer_return.rb +2 -0
- data/app/models/spree/item_total.rb +28 -0
- data/app/models/spree/legacy_user.rb +1 -0
- data/app/models/spree/line_item.rb +21 -0
- data/app/models/spree/money.rb +120 -0
- data/app/models/spree/order.rb +20 -9
- data/app/models/spree/order_merger.rb +1 -1
- data/app/models/spree/order_taxation.rb +1 -0
- data/app/models/spree/order_updater.rb +13 -30
- data/app/models/spree/payment.rb +1 -0
- data/app/models/spree/permission_sets/base.rb +45 -0
- data/app/models/spree/permission_sets/configuration_display.rb +53 -0
- data/app/models/spree/permission_sets/configuration_management.rb +52 -0
- data/app/models/spree/permission_sets/dashboard_display.rb +28 -0
- data/app/models/spree/permission_sets/default_customer.rb +83 -0
- data/app/models/spree/permission_sets/order_display.rb +50 -0
- data/app/models/spree/permission_sets/order_management.rb +50 -0
- data/app/models/spree/permission_sets/product_display.rb +43 -0
- data/app/models/spree/permission_sets/product_management.rb +47 -0
- data/app/models/spree/permission_sets/restricted_stock_display.rb +33 -0
- data/app/models/spree/permission_sets/restricted_stock_management.rb +33 -0
- data/app/models/spree/permission_sets/stock_display.rb +26 -0
- data/app/models/spree/permission_sets/stock_management.rb +26 -0
- data/app/models/spree/permission_sets/super_user.rb +26 -0
- data/app/models/spree/permission_sets/user_display.rb +27 -0
- data/app/models/spree/permission_sets/user_management.rb +44 -0
- data/app/models/spree/product.rb +7 -0
- data/app/models/spree/refund.rb +2 -0
- data/app/models/spree/return_authorization.rb +2 -0
- data/app/models/spree/shipment.rb +2 -0
- data/app/models/spree/simple_order_contents.rb +4 -1
- data/app/models/spree/store_credit_event.rb +1 -0
- data/app/models/spree/tax/tax_helpers.rb +12 -1
- data/app/models/spree/tax_calculator/default.rb +1 -1
- data/app/models/spree/taxon.rb +22 -2
- data/app/models/spree/taxon_brand_selector.rb +22 -0
- data/app/models/spree/unauthorized_redirect_handler.rb +24 -0
- data/app/models/spree/user_address.rb +9 -3
- data/app/models/spree/variant.rb +14 -1
- data/config/locales/en.yml +14 -0
- data/db/migrate/20220419170826_remove_archived_user_addresses.rb +12 -0
- data/db/migrate/20250129061658_add_metadata_to_spree_resources.rb +29 -0
- data/db/migrate/20250201172950_add_gtin_and_condition_to_spree_variant.rb +6 -0
- data/db/migrate/20250207104016_add_primary_taxon_to_products.rb +7 -0
- data/lib/generators/solidus/install/app_templates/authentication/custom.rb +0 -5
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +1 -1
- data/lib/generators/spree/dummy/dummy_generator.rb +1 -1
- data/lib/generators/spree/dummy/templates/rails/application.rb.tt +1 -1
- data/lib/generators/spree/dummy/templates/rails/manifest.js +3 -0
- data/lib/spree/app_configuration.rb +49 -0
- data/lib/spree/core/controller_helpers/auth.rb +5 -61
- data/lib/spree/core/controller_helpers/common.rb +5 -80
- data/lib/spree/core/controller_helpers/order.rb +5 -86
- data/lib/spree/core/controller_helpers/payment_parameters.rb +5 -163
- data/lib/spree/core/controller_helpers/pricing.rb +5 -17
- data/lib/spree/core/controller_helpers/search.rb +5 -14
- data/lib/spree/core/controller_helpers/store.rb +5 -17
- data/lib/spree/core/controller_helpers/strong_parameters.rb +5 -71
- data/lib/spree/core/engine.rb +5 -0
- data/lib/spree/core/state_machines/inventory_unit.rb +5 -40
- data/lib/spree/core/state_machines/order.rb +5 -250
- data/lib/spree/core/state_machines/payment.rb +5 -59
- data/lib/spree/core/state_machines/reimbursement.rb +5 -31
- data/lib/spree/core/state_machines/return_authorization.rb +5 -30
- data/lib/spree/core/state_machines/return_item/acceptance_status.rb +5 -49
- data/lib/spree/core/state_machines/return_item/reception_status.rb +5 -40
- data/lib/spree/core/state_machines/shipment.rb +5 -56
- data/lib/spree/core/state_machines.rb +48 -81
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +0 -10
- data/lib/spree/money.rb +5 -118
- data/lib/spree/permission_sets/base.rb +5 -42
- data/lib/spree/permission_sets/configuration_display.rb +5 -51
- data/lib/spree/permission_sets/configuration_management.rb +5 -50
- data/lib/spree/permission_sets/dashboard_display.rb +5 -26
- data/lib/spree/permission_sets/default_customer.rb +5 -81
- data/lib/spree/permission_sets/order_display.rb +5 -48
- data/lib/spree/permission_sets/order_management.rb +5 -48
- data/lib/spree/permission_sets/product_display.rb +5 -41
- data/lib/spree/permission_sets/product_management.rb +5 -45
- data/lib/spree/permission_sets/restricted_stock_display.rb +5 -31
- data/lib/spree/permission_sets/restricted_stock_management.rb +5 -31
- data/lib/spree/permission_sets/stock_display.rb +5 -24
- data/lib/spree/permission_sets/stock_management.rb +5 -24
- data/lib/spree/permission_sets/super_user.rb +5 -24
- data/lib/spree/permission_sets/user_display.rb +5 -25
- data/lib/spree/permission_sets/user_management.rb +5 -42
- data/lib/spree/permission_sets.rb +5 -16
- data/lib/spree/permitted_attributes.rb +18 -7
- data/lib/spree/preferences/configuration.rb +4 -0
- data/lib/spree/preferences/persistable.rb +1 -1
- data/lib/spree/testing_support/capybara_ext.rb +10 -0
- data/lib/spree/testing_support/dummy_app.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +9 -1
- data/solidus_core.gemspec +1 -1
- metadata +64 -24
- data/lib/generators/spree/dummy/templates/rails/script/rails +0 -6
@@ -2,87 +2,54 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module Core
|
5
|
-
class StateMachines
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
require 'spree/core/state_machines/inventory_unit'
|
54
|
-
'Spree::Core::StateMachines::InventoryUnit'
|
55
|
-
end
|
56
|
-
|
57
|
-
@inventory_unit.constantize
|
58
|
-
end
|
59
|
-
|
60
|
-
def shipment
|
61
|
-
@shipment ||= begin
|
62
|
-
require 'spree/core/state_machines/shipment'
|
63
|
-
'Spree::Core::StateMachines::Shipment'
|
64
|
-
end
|
65
|
-
|
66
|
-
@shipment.constantize
|
67
|
-
end
|
68
|
-
|
69
|
-
def order
|
70
|
-
@order ||= begin
|
71
|
-
require 'spree/core/state_machines/order'
|
72
|
-
'Spree::Core::StateMachines::Order'
|
73
|
-
end
|
74
|
-
|
75
|
-
@order.constantize
|
76
|
-
end
|
77
|
-
|
78
|
-
def reimbursement
|
79
|
-
@reimbursement ||= begin
|
80
|
-
require 'spree/core/state_machines/reimbursement'
|
81
|
-
'Spree::Core::StateMachines::Reimbursement'
|
82
|
-
end
|
83
|
-
|
84
|
-
@reimbursement.constantize
|
85
|
-
end
|
5
|
+
class StateMachines < Spree::Preferences::Configuration
|
6
|
+
# State Machine module for Reimbursements
|
7
|
+
#
|
8
|
+
# @!attribute [rw] reimbursement
|
9
|
+
# @return [Module] a module that implements the state machine for the `Spree::Reimbursement` model.
|
10
|
+
class_name_attribute :reimbursement, default: "Spree::Core::StateMachines::Reimbursement"
|
11
|
+
|
12
|
+
# State Machine module for Return Authorizations
|
13
|
+
#
|
14
|
+
# @!attribute [rw] return_authorization
|
15
|
+
# @return [Module] a module that implements the state machine for the `Spree::ReturnAuthorization` model.
|
16
|
+
class_name_attribute :return_authorization, default: "Spree::Core::StateMachines::ReturnAuthorization"
|
17
|
+
|
18
|
+
# State Machine module for Return Item Acceptances
|
19
|
+
#
|
20
|
+
# @!attribute [rw] return_item_acceptance
|
21
|
+
# @return [Module] a module that implements the acceptance part of the state machine for the `Spree::ReturnItem` model.
|
22
|
+
class_name_attribute :return_item_acceptance, default: "Spree::Core::StateMachines::ReturnItem::AcceptanceStatus"
|
23
|
+
|
24
|
+
# State Machine module for Return Item Receptions
|
25
|
+
#
|
26
|
+
# @!attribute [rw] return_item_reception
|
27
|
+
# @return [Module] a module that implements the reception part of the state machine for the `Spree::ReturnItem` model.
|
28
|
+
class_name_attribute :return_item_reception, default: "Spree::Core::StateMachines::ReturnItem::ReceptionStatus"
|
29
|
+
|
30
|
+
# State Machine module for Payments
|
31
|
+
#
|
32
|
+
# @!attribute [rw] payment
|
33
|
+
# @return [Module] a module that implements the state machine for the `Spree::Payment` model.
|
34
|
+
class_name_attribute :payment, default: "Spree::Core::StateMachines::Payment"
|
35
|
+
|
36
|
+
# State Machine module for Inventory Units
|
37
|
+
#
|
38
|
+
# @!attribute [rw] inventory_unit
|
39
|
+
# @return [Module] a module that implements the state machine for the `Spree::InventoryUnit` model.
|
40
|
+
class_name_attribute :inventory_unit, default: "Spree::Core::StateMachines::InventoryUnit"
|
41
|
+
|
42
|
+
# State Machine module for Shipments
|
43
|
+
#
|
44
|
+
# @!attribute [rw] shipment
|
45
|
+
# @return [Module] a module that implements the state machine for the `Spree::Shipment` model.
|
46
|
+
class_name_attribute :shipment, default: "Spree::Core::StateMachines::Shipment"
|
47
|
+
|
48
|
+
# State Machine module for Orders
|
49
|
+
#
|
50
|
+
# @!attribute [rw] order
|
51
|
+
# @return [Module] a module that implements the state machine for the `Spree::Order` model.
|
52
|
+
class_name_attribute :order, default: "Spree::Core::StateMachines::Order"
|
86
53
|
end
|
87
54
|
end
|
88
55
|
end
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
@@ -105,26 +105,16 @@ require 'spree/core/engine'
|
|
105
105
|
|
106
106
|
require 'spree/i18n'
|
107
107
|
require 'spree/localized_number'
|
108
|
-
require 'spree/money'
|
109
108
|
require 'spree/permitted_attributes'
|
110
109
|
|
111
110
|
require 'spree/core/importer'
|
112
111
|
require 'spree/core/permalinks'
|
113
112
|
require 'spree/core/product_duplicator'
|
114
|
-
require 'spree/core/controller_helpers/auth'
|
115
|
-
require 'spree/core/controller_helpers/common'
|
116
|
-
require 'spree/core/controller_helpers/order'
|
117
|
-
require 'spree/core/controller_helpers/payment_parameters'
|
118
|
-
require 'spree/core/controller_helpers/pricing'
|
119
|
-
require 'spree/core/controller_helpers/search'
|
120
|
-
require 'spree/core/controller_helpers/store'
|
121
|
-
require 'spree/core/controller_helpers/strong_parameters'
|
122
113
|
require 'spree/core/role_configuration'
|
123
114
|
require 'spree/core/state_machines'
|
124
115
|
require 'spree/core/stock_configuration'
|
125
116
|
require 'spree/core/null_promotion_configuration'
|
126
117
|
require 'spree/core/validators/email'
|
127
|
-
require 'spree/permission_sets'
|
128
118
|
require 'spree/user_class_handle'
|
129
119
|
|
130
120
|
require 'spree/preferences/store'
|
data/lib/spree/money.rb
CHANGED
@@ -1,120 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
DifferentCurrencyError = Class.new(StandardError)
|
9
|
-
|
10
|
-
class <<self
|
11
|
-
attr_accessor :default_formatting_rules
|
12
|
-
|
13
|
-
def parse(amount, currency = Spree::Config[:currency])
|
14
|
-
new(parse_to_money(amount, currency))
|
15
|
-
end
|
16
|
-
|
17
|
-
# @api private
|
18
|
-
def parse_to_money(amount, currency)
|
19
|
-
::Monetize.parse(amount, currency)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
self.default_formatting_rules = {
|
23
|
-
# Ruby money currently has this as false, which is wrong for the vast
|
24
|
-
# majority of locales.
|
25
|
-
sign_before_symbol: true
|
26
|
-
}
|
27
|
-
|
28
|
-
attr_reader :money
|
29
|
-
|
30
|
-
delegate :cents, :currency, :to_d, :zero?, to: :money
|
31
|
-
|
32
|
-
# @param amount [Money, #to_s] the value of the money object
|
33
|
-
# @param options [Hash] the default options for formatting the money object See #format
|
34
|
-
def initialize(amount, options = {})
|
35
|
-
if amount.is_a?(::Money)
|
36
|
-
@money = amount
|
37
|
-
else
|
38
|
-
currency = options[:currency] || Spree::Config[:currency]
|
39
|
-
|
40
|
-
@money = Monetize.from_string(amount, currency)
|
41
|
-
end
|
42
|
-
@options = Spree::Money.default_formatting_rules.merge(options)
|
43
|
-
end
|
44
|
-
|
45
|
-
# @return [String] the value of this money object formatted according to
|
46
|
-
# its options
|
47
|
-
def to_s
|
48
|
-
format
|
49
|
-
end
|
50
|
-
|
51
|
-
# @param options [Hash, String] the options for formatting the money object
|
52
|
-
# @option options [Boolean] with_currency when true, show the currency
|
53
|
-
# @option options [Boolean] no_cents when true, round to the closest dollar
|
54
|
-
# @option options [String] decimal_mark the mark for delimiting the
|
55
|
-
# decimals
|
56
|
-
# @option options [String, false, nil] thousands_separator the character to
|
57
|
-
# delimit powers of 1000, if one is desired, otherwise false or nil
|
58
|
-
# @option options [Boolean] sign_before_symbol when true the sign of the
|
59
|
-
# value comes before the currency symbol
|
60
|
-
# @option options [:before, :after] symbol_position the position of the
|
61
|
-
# currency symbol
|
62
|
-
# @return [String] the value of this money object formatted according to
|
63
|
-
# its options
|
64
|
-
def format(options = {})
|
65
|
-
@money.format(@options.merge(options))
|
66
|
-
end
|
67
|
-
|
68
|
-
# @note If you pass in options, ensure you pass in the { html_wrap: true } as well.
|
69
|
-
# @param options [Hash] additional formatting options
|
70
|
-
# @return [String] the value of this money object formatted according to
|
71
|
-
# its options and any additional options, by default with html_wrap.
|
72
|
-
def to_html(options = { html_wrap: true })
|
73
|
-
output = format(options)
|
74
|
-
# Maintain compatibility by checking html option renamed to html_wrap.
|
75
|
-
if options[:html_wrap]
|
76
|
-
output = output.html_safe
|
77
|
-
end
|
78
|
-
output
|
79
|
-
end
|
80
|
-
|
81
|
-
# (see #to_s)
|
82
|
-
def as_json(*)
|
83
|
-
to_s
|
84
|
-
end
|
85
|
-
|
86
|
-
def <=>(other)
|
87
|
-
if !other.respond_to?(:money)
|
88
|
-
raise TypeError, "Can't compare #{other.class} to Spree::Money"
|
89
|
-
end
|
90
|
-
if currency != other.currency
|
91
|
-
# By default, ::Money will try to run a conversion on `other.money` and
|
92
|
-
# try a comparison on that. We do not want any currency conversion to
|
93
|
-
# take place so we'll catch this here and raise an error.
|
94
|
-
raise(
|
95
|
-
DifferentCurrencyError,
|
96
|
-
"Can't compare #{currency} with #{other.currency}"
|
97
|
-
)
|
98
|
-
end
|
99
|
-
@money <=> other.money
|
100
|
-
end
|
101
|
-
|
102
|
-
# Delegates comparison to the internal ruby money instance.
|
103
|
-
#
|
104
|
-
# @see http://www.rubydoc.info/gems/money/Money/Arithmetic#%3D%3D-instance_method
|
105
|
-
def ==(other)
|
106
|
-
raise TypeError, "Can't compare #{other.class} to Spree::Money" if !other.respond_to?(:money)
|
107
|
-
@money == other.money
|
108
|
-
end
|
109
|
-
|
110
|
-
def -(other)
|
111
|
-
raise TypeError, "Can't subtract #{other.class} to Spree::Money" if !other.respond_to?(:money)
|
112
|
-
self.class.new(@money - other.money)
|
113
|
-
end
|
114
|
-
|
115
|
-
def +(other)
|
116
|
-
raise TypeError, "Can't add #{other.class} to Spree::Money" if !other.respond_to?(:money)
|
117
|
-
self.class.new(@money + other.money)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,44 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
# See one of the subclasses for example structure such as {Spree::PermissionSets::UserDisplay}
|
9
|
-
#
|
10
|
-
# @see Spree::RoleConfiguration
|
11
|
-
# @see Spree::PermissionSets
|
12
|
-
class Base
|
13
|
-
# @param ability [CanCan::Ability]
|
14
|
-
# The ability that will be extended with the current permission set.
|
15
|
-
# The ability passed in must respond to #user
|
16
|
-
def initialize(ability)
|
17
|
-
@ability = ability
|
18
|
-
end
|
19
|
-
|
20
|
-
# Activate permissions on the ability. Put your can and cannot statements here.
|
21
|
-
# Must be overridden by subclasses
|
22
|
-
def activate!
|
23
|
-
raise NotImplementedError.new
|
24
|
-
end
|
25
|
-
|
26
|
-
# Provide the permission set privilege in the form of a :symbol.
|
27
|
-
# Must be overridden by subclasses.
|
28
|
-
def self.privilege
|
29
|
-
raise NotImplementedError, "Subclass #{name} must define a privilege using `self.privilege :symbol`"
|
30
|
-
end
|
31
|
-
|
32
|
-
# Provide the permission set category in the form of a :symbol.
|
33
|
-
# Must be overridden by subclasses.
|
34
|
-
def self.category
|
35
|
-
raise NotImplementedError, "Subclass #{name} must define a category using `self.category :symbol`"
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
attr_reader :ability
|
41
|
-
delegate :can, :cannot, :user, to: :ability
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,53 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
# panel, about:
|
9
|
-
#
|
10
|
-
# - Tax categories
|
11
|
-
# - Tax rates
|
12
|
-
# - Zones
|
13
|
-
# - Countries
|
14
|
-
# - States
|
15
|
-
# - Payment methods
|
16
|
-
# - Taxonomies
|
17
|
-
# - Shipping methods
|
18
|
-
# - Shipping categories
|
19
|
-
# - Stock locations
|
20
|
-
# - Stock movements
|
21
|
-
# - Refund reasons
|
22
|
-
# - Reimbursement types
|
23
|
-
# - Return reasons
|
24
|
-
class ConfigurationDisplay < PermissionSets::Base
|
25
|
-
class << self
|
26
|
-
def privilege
|
27
|
-
:display
|
28
|
-
end
|
29
|
-
|
30
|
-
def category
|
31
|
-
:configuration
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def activate!
|
36
|
-
can [:read, :admin], Spree::TaxCategory
|
37
|
-
can [:read, :admin], Spree::TaxRate
|
38
|
-
can [:read, :admin], Spree::Zone
|
39
|
-
can [:read, :admin], Spree::Country
|
40
|
-
can [:read, :admin], Spree::State
|
41
|
-
can [:read, :admin], Spree::PaymentMethod
|
42
|
-
can [:read, :admin], Spree::Taxonomy
|
43
|
-
can [:read, :admin], Spree::ShippingMethod
|
44
|
-
can [:read, :admin], Spree::ShippingCategory
|
45
|
-
can [:read, :admin], Spree::StockLocation
|
46
|
-
can [:read, :admin], Spree::StockMovement
|
47
|
-
can [:read, :admin], Spree::RefundReason
|
48
|
-
can [:read, :admin], Spree::ReimbursementType
|
49
|
-
can [:read, :admin], Spree::ReturnReason
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,52 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
# - Tax categories
|
10
|
-
# - Tax rates
|
11
|
-
# - Zones
|
12
|
-
# - Countries
|
13
|
-
# - States
|
14
|
-
# - Payment methods
|
15
|
-
# - Taxonomies
|
16
|
-
# - Shipping methods
|
17
|
-
# - Shipping categories
|
18
|
-
# - Stock locations
|
19
|
-
# - Stock movements
|
20
|
-
# - Refund reasons
|
21
|
-
# - Reimbursement types
|
22
|
-
# - Return reasons
|
23
|
-
class ConfigurationManagement < PermissionSets::Base
|
24
|
-
class << self
|
25
|
-
def privilege
|
26
|
-
:management
|
27
|
-
end
|
28
|
-
|
29
|
-
def category
|
30
|
-
:configuration
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def activate!
|
35
|
-
can :manage, Spree::TaxCategory
|
36
|
-
can :manage, Spree::TaxRate
|
37
|
-
can :manage, Spree::Zone
|
38
|
-
can :manage, Spree::Country
|
39
|
-
can :manage, Spree::State
|
40
|
-
can :manage, Spree::PaymentMethod
|
41
|
-
can :manage, Spree::Taxonomy
|
42
|
-
can :manage, Spree::ShippingMethod
|
43
|
-
can :manage, Spree::ShippingCategory
|
44
|
-
can :manage, Spree::StockLocation
|
45
|
-
can :manage, Spree::StockMovement
|
46
|
-
can :manage, Spree::RefundReason
|
47
|
-
can :manage, Spree::ReimbursementType
|
48
|
-
can :manage, Spree::ReturnReason
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,28 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
# which may or not contain sensitive information depending on
|
9
|
-
# customizations.
|
10
|
-
class DashboardDisplay < PermissionSets::Base
|
11
|
-
class << self
|
12
|
-
def privilege
|
13
|
-
:other
|
14
|
-
end
|
15
|
-
|
16
|
-
def category
|
17
|
-
:dashboard_display
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def activate!
|
22
|
-
Spree.deprecator.warn "The #{self.class.name} module is deprecated. " \
|
23
|
-
"If you still use dashboards, please copy all controllers and views from #{self.class.name} to your application."
|
24
|
-
can [:admin, :home], :dashboards
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,83 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
# is the default role for all users without any explicit roles.
|
9
|
-
#
|
10
|
-
# Permissions include reading and updating orders when the ability's user
|
11
|
-
# has been assigned as the order's user, unless the order is already
|
12
|
-
# completed. Same is true for guest checkout orders.
|
13
|
-
#
|
14
|
-
# It grants read-only permissions for the following resources typically used
|
15
|
-
# during a checkout process:
|
16
|
-
#
|
17
|
-
# - Zones
|
18
|
-
# - Countries
|
19
|
-
# - States
|
20
|
-
# - Taxons
|
21
|
-
# - Taxonomies
|
22
|
-
# - Products
|
23
|
-
# - Properties
|
24
|
-
# - Product properties
|
25
|
-
# - Variants
|
26
|
-
# - Option types
|
27
|
-
# - Option values
|
28
|
-
# - Stock items
|
29
|
-
# - Stock locations
|
30
|
-
#
|
31
|
-
# Abilities with this role can also create refund authorizations for orders
|
32
|
-
# with the same user, as well as reading and updating the user record and
|
33
|
-
# their associated cards.
|
34
|
-
class DefaultCustomer < PermissionSets::Base
|
35
|
-
class << self
|
36
|
-
def privilege
|
37
|
-
:other
|
38
|
-
end
|
39
|
-
|
40
|
-
def category
|
41
|
-
:default_customer
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def activate!
|
46
|
-
can :read, Country
|
47
|
-
can :read, OptionType
|
48
|
-
can :read, OptionValue
|
49
|
-
can :create, Order do |order, token|
|
50
|
-
# same user, or both nil
|
51
|
-
order.user == user ||
|
52
|
-
# guest checkout order
|
53
|
-
order.email.present? ||
|
54
|
-
# via API, just like with show and update
|
55
|
-
(order.guest_token.present? && token == order.guest_token)
|
56
|
-
end
|
57
|
-
can [:show, :update], Order, Order.where(user:) do |order, token|
|
58
|
-
order.user == user || (order.guest_token.present? && token == order.guest_token)
|
59
|
-
end
|
60
|
-
cannot :update, Order do |order|
|
61
|
-
order.completed?
|
62
|
-
end
|
63
|
-
can :create, ReturnAuthorization do |return_authorization|
|
64
|
-
return_authorization.order.user == user
|
65
|
-
end
|
66
|
-
can [:read, :update], CreditCard, user_id: user.id
|
67
|
-
can :read, Product
|
68
|
-
can :read, ProductProperty
|
69
|
-
can :read, Property
|
70
|
-
can :create, Spree.user_class
|
71
|
-
can [:show, :update, :update_email], Spree.user_class, id: user.id
|
72
|
-
can :read, State
|
73
|
-
can :read, StockItem, stock_location: { active: true }
|
74
|
-
can :read, StockLocation, active: true
|
75
|
-
can :read, Taxon
|
76
|
-
can :read, Taxonomy
|
77
|
-
can [:save_in_address_book, :remove_from_address_book], Spree.user_class, id: user.id
|
78
|
-
can [:read, :view_out_of_stock], Variant
|
79
|
-
can :read, Zone
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|
@@ -1,50 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
# orders, also from the admin panel, including:
|
9
|
-
#
|
10
|
-
# - Orders
|
11
|
-
# - Payments
|
12
|
-
# - Shipments
|
13
|
-
# - Adjustments
|
14
|
-
# - Line items
|
15
|
-
# - Return authorizations
|
16
|
-
# - Customer returns
|
17
|
-
# - Order cancellations
|
18
|
-
# - Reimbursements
|
19
|
-
# - Return items
|
20
|
-
# - Refunds
|
21
|
-
#
|
22
|
-
# However, it does not allow any modifications to be made to any of these
|
23
|
-
# resources.
|
24
|
-
class OrderDisplay < PermissionSets::Base
|
25
|
-
class << self
|
26
|
-
def privilege
|
27
|
-
:display
|
28
|
-
end
|
29
|
-
|
30
|
-
def category
|
31
|
-
:order
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def activate!
|
36
|
-
can [:read, :admin, :edit, :cart], Spree::Order
|
37
|
-
can [:read, :admin], Spree::Payment
|
38
|
-
can [:read, :admin], Spree::Shipment
|
39
|
-
can [:read, :admin], Spree::Adjustment
|
40
|
-
can [:read, :admin], Spree::LineItem
|
41
|
-
can [:read, :admin], Spree::ReturnAuthorization
|
42
|
-
can [:read, :admin], Spree::CustomerReturn
|
43
|
-
can [:read, :admin], Spree::OrderCancellations
|
44
|
-
can [:read, :admin], Spree::Reimbursement
|
45
|
-
can [:read, :admin], Spree::ReturnItem
|
46
|
-
can [:read, :admin], Spree::Refund
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
3
|
+
Spree.deprecator.warn(
|
4
|
+
<<~MSG
|
5
|
+
The file "#{__FILE__}" does not need to be `require`d any longer, it is now autoloaded.
|
6
|
+
MSG
|
7
|
+
)
|