solidus_core 3.4.2 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/spree/base_controller.rb +0 -2
- data/app/helpers/spree/products_helper.rb +1 -1
- data/app/models/concerns/spree/active_storage_adapter.rb +0 -17
- data/app/models/concerns/spree/default_price.rb +0 -15
- data/app/models/concerns/spree/ransackable_attributes.rb +0 -21
- data/app/models/spree/adjustment.rb +0 -13
- data/app/models/spree/carton.rb +1 -1
- data/app/models/spree/fulfilment_changer.rb +2 -14
- data/app/models/spree/option_value.rb +2 -11
- data/app/models/spree/order.rb +23 -39
- data/app/models/spree/order_contents.rb +2 -2
- data/app/models/spree/order_merger.rb +2 -4
- data/app/models/spree/order_updater.rb +3 -30
- data/app/models/spree/payment.rb +5 -37
- data/app/models/spree/product/scopes.rb +0 -5
- data/app/models/spree/product.rb +3 -10
- data/app/models/spree/promotion/rules/item_total.rb +0 -11
- data/app/models/spree/promotion.rb +7 -30
- data/app/models/spree/promotion_rule.rb +0 -5
- data/app/models/spree/refund.rb +1 -1
- data/app/models/spree/taxon/paperclip_attachment.rb +1 -1
- data/app/models/spree/taxon.rb +2 -2
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/variant/price_selector.rb +1 -14
- data/app/models/spree/variant.rb +1 -17
- data/bin/rails +13 -0
- data/config/locales/en.yml +0 -1
- data/db/migrate/20210815004823_add_unique_index_to_option_values_variants.rb +16 -0
- data/db/migrate/20230321161854_change_column_null_option_values_option_type_id.rb +5 -0
- data/db/migrate/20230322085416_remove_match_policy_from_spree_promotion.rb +5 -0
- data/db/migrate/20230325132905_remove_unused_columns_from_promotion_rules.rb +6 -0
- data/db/migrate/20230325161633_drop_unused_promo_action_line_items.rb +13 -0
- data/db/migrate/20230425103509_remove_taxon_position.rb +5 -0
- data/db/migrate/20230427095534_drop_deprecated_address_id_from_shipments.rb +11 -0
- data/lib/generators/solidus/install/app_templates/frontend/none.rb +1 -2
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +1 -3
- data/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +2 -14
- data/lib/generators/solidus/install/app_templates/payment_method/stripe.rb +5 -0
- data/lib/generators/solidus/install/install_generator.rb +59 -153
- data/lib/spree/app_configuration.rb +10 -82
- data/lib/spree/bus.rb +2 -11
- data/lib/spree/core/controller_helpers/auth.rb +0 -16
- data/lib/spree/core/engine.rb +11 -31
- data/lib/spree/core/importer/order.rb +1 -1
- data/lib/spree/core/validators/email.rb +0 -4
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +0 -2
- data/lib/spree/migration_helpers.rb +3 -3
- data/lib/spree/permission_sets/configuration_display.rb +19 -1
- data/lib/spree/permission_sets/configuration_management.rb +18 -1
- data/lib/spree/permission_sets/dashboard_display.rb +5 -0
- data/lib/spree/permission_sets/default_customer.rb +29 -0
- data/lib/spree/permission_sets/order_display.rb +19 -0
- data/lib/spree/permission_sets/order_management.rb +18 -0
- data/lib/spree/permission_sets/product_display.rb +14 -0
- data/lib/spree/permission_sets/product_management.rb +16 -0
- data/lib/spree/permission_sets/promotion_display.rb +10 -0
- data/lib/spree/permission_sets/promotion_management.rb +10 -0
- data/lib/spree/permission_sets/restricted_stock_display.rb +5 -0
- data/lib/spree/permission_sets/restricted_stock_management.rb +5 -0
- data/lib/spree/permission_sets/stock_display.rb +4 -0
- data/lib/spree/permission_sets/stock_management.rb +4 -0
- data/lib/spree/permission_sets/super_user.rb +5 -0
- data/lib/spree/permission_sets/user_display.rb +4 -0
- data/lib/spree/permission_sets/user_management.rb +9 -0
- data/lib/spree/preferences/preferable_class_methods.rb +1 -25
- data/lib/spree/testing_support/common_rake.rb +5 -1
- data/lib/spree/testing_support/dummy_app/rake_tasks.rb +4 -8
- data/lib/spree/testing_support/dummy_app.rb +1 -7
- data/lib/spree/testing_support/factories/address_factory.rb +0 -7
- data/lib/spree/testing_support/factories/adjustment_factory.rb +0 -11
- data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/calculator_factory.rb +0 -5
- data/lib/spree/testing_support/factories/carton_factory.rb +0 -8
- data/lib/spree/testing_support/factories/country_factory.rb +0 -5
- data/lib/spree/testing_support/factories/credit_card_factory.rb +0 -5
- data/lib/spree/testing_support/factories/customer_return_factory.rb +0 -9
- data/lib/spree/testing_support/factories/image_factory.rb +0 -5
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +0 -10
- data/lib/spree/testing_support/factories/line_item_factory.rb +0 -8
- data/lib/spree/testing_support/factories/option_type_factory.rb +0 -8
- data/lib/spree/testing_support/factories/option_value_factory.rb +0 -5
- data/lib/spree/testing_support/factories/order_factory.rb +0 -12
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +0 -8
- data/lib/spree/testing_support/factories/payment_factory.rb +0 -10
- data/lib/spree/testing_support/factories/payment_method_factory.rb +0 -5
- data/lib/spree/testing_support/factories/price_factory.rb +0 -7
- data/lib/spree/testing_support/factories/product_factory.rb +0 -11
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +0 -8
- data/lib/spree/testing_support/factories/product_property_factory.rb +0 -8
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +0 -5
- data/lib/spree/testing_support/factories/promotion_code_factory.rb +0 -8
- data/lib/spree/testing_support/factories/promotion_factory.rb +0 -8
- data/lib/spree/testing_support/factories/property_factory.rb +0 -5
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -8
- data/lib/spree/testing_support/factories/refund_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +0 -7
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +0 -5
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +0 -9
- data/lib/spree/testing_support/factories/return_item_factory.rb +0 -9
- data/lib/spree/testing_support/factories/return_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/role_factory.rb +0 -5
- data/lib/spree/testing_support/factories/shipment_factory.rb +0 -10
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +0 -5
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +0 -9
- data/lib/spree/testing_support/factories/shipping_rate_factory.rb +0 -8
- data/lib/spree/testing_support/factories/state_factory.rb +0 -8
- data/lib/spree/testing_support/factories/stock_item_factory.rb +0 -8
- data/lib/spree/testing_support/factories/stock_location_factory.rb +0 -9
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +0 -7
- data/lib/spree/testing_support/factories/stock_package_factory.rb +0 -8
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +0 -5
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +0 -8
- data/lib/spree/testing_support/factories/store_credit_factory.rb +0 -9
- data/lib/spree/testing_support/factories/store_credit_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +0 -5
- data/lib/spree/testing_support/factories/store_factory.rb +0 -5
- data/lib/spree/testing_support/factories/tax_category_factory.rb +0 -8
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +0 -9
- data/lib/spree/testing_support/factories/taxon_factory.rb +0 -7
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +0 -5
- data/lib/spree/testing_support/factories/user_factory.rb +0 -9
- data/lib/spree/testing_support/factories/variant_factory.rb +0 -10
- data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +0 -8
- data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +0 -9
- data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +0 -8
- data/lib/spree/testing_support/factories/zone_factory.rb +0 -8
- data/lib/spree/testing_support/factory_bot.rb +4 -28
- data/lib/spree/testing_support/sequences.rb +0 -5
- data/solidus_core.gemspec +3 -3
- metadata +48 -58
- data/app/subscribers/spree/mailer_subscriber.rb +0 -29
- data/lib/generators/solidus/install/app_templates/frontend/break_down_solidus_gem.rb +0 -54
- data/lib/generators/solidus/install/app_templates/frontend/classic.rb +0 -16
- data/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +0 -13
- data/lib/spree/core/controller_helpers/current_host.rb +0 -19
- data/lib/spree/event/adapters/active_support_notifications.rb +0 -67
- data/lib/spree/event/configuration.rb +0 -25
- data/lib/spree/event/subscriber.rb +0 -86
- data/lib/spree/event/subscriber_registry.rb +0 -92
- data/lib/spree/event.rb +0 -119
- data/lib/spree/promotion/match_policies.rb +0 -2
- data/lib/spree/rails_compatibility.rb +0 -106
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/frontend/all.js +0 -10
- data/lib/spree/testing_support/dummy_app/assets/stylesheets/spree/frontend/all.css +0 -9
- data/lib/spree/testing_support/dummy_app/views/layouts/application.html.erb +0 -1
- data/lib/spree/testing_support/factories.rb +0 -11
- data/lib/spree/testing_support.rb +0 -36
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +0 -18
- data/lib/tasks/solidus/split_promotions_with_any_match_policy.rake +0 -33
@@ -21,7 +21,6 @@ require "spree/core/search/base"
|
|
21
21
|
require "spree/core/search/variant"
|
22
22
|
require 'spree/preferences/configuration'
|
23
23
|
require 'spree/core/environment'
|
24
|
-
require 'spree/rails_compatibility'
|
25
24
|
|
26
25
|
module Spree
|
27
26
|
class AppConfiguration < Preferences::Configuration
|
@@ -61,27 +60,6 @@ module Spree
|
|
61
60
|
# @return [Boolean] When false, customers must create an account to complete an order (default: +true+)
|
62
61
|
preference :allow_guest_checkout, :boolean, default: true
|
63
62
|
|
64
|
-
# @!attribute [rw] allow_promotions_any_match_policy
|
65
|
-
# @return [Boolean] When false, admins cannot create promotions with an "any" match policy (default: +false+)
|
66
|
-
# Create individual, separate promotions for each of your rules instead.
|
67
|
-
preference :allow_promotions_any_match_policy, :boolean, default: false
|
68
|
-
def allow_promotions_any_match_policy=(value)
|
69
|
-
if value == true
|
70
|
-
Spree::Deprecation.warn <<~MSG
|
71
|
-
Solidus 4.0 will remove support for combining promotion rules with the "any" match policy.
|
72
|
-
|
73
|
-
Instead, it's suggested to create individual, separate promotions for each of your current
|
74
|
-
rules combined with the "any" policy. To automate this task, you can use the provided
|
75
|
-
task:
|
76
|
-
|
77
|
-
bin/rake solidus:split_promotions_with_any_match_policy
|
78
|
-
MSG
|
79
|
-
end
|
80
|
-
|
81
|
-
preferences[:allow_promotions_any_match_policy] = value
|
82
|
-
end
|
83
|
-
|
84
|
-
|
85
63
|
# @!attribute [rw] guest_token_cookie_options
|
86
64
|
# @return [Hash] Add additional guest_token cookie options here (ie. domain or path)
|
87
65
|
preference :guest_token_cookie_options, :hash, default: {}
|
@@ -171,38 +149,6 @@ module Spree
|
|
171
149
|
# @return [Regexp] Regex to be used in email validations, for example in Spree::EmailValidator
|
172
150
|
preference :default_email_regexp, :regexp, default: URI::MailTo::EMAIL_REGEXP
|
173
151
|
|
174
|
-
# @!attribute [rw] extra_taxon_validations
|
175
|
-
# Use extra validations on Taxons in 3.4.0, but default to false so stores can
|
176
|
-
# upgrade and then fix any now invalid Taxons before enabling.
|
177
|
-
# @return [Boolean]
|
178
|
-
versioned_preference :extra_taxon_validations, :boolean, initial_value: false, boundaries: { "3.4.0.dev" => true }
|
179
|
-
def extra_taxon_validations=(value)
|
180
|
-
Spree::Deprecation.warn <<~MSG
|
181
|
-
Solidus will remove `Spree::Config.extra_taxon_validations` preference
|
182
|
-
in the next major release and will always use the extra Taxon validations.
|
183
|
-
Before upgrading to the next major, please fix any now invalid Taxons
|
184
|
-
and then remove the preference definition in `config/initializers/spree.rb`.
|
185
|
-
MSG
|
186
|
-
|
187
|
-
preferences[:extra_taxon_validations] = value
|
188
|
-
end
|
189
|
-
|
190
|
-
# @!attribute [rw] extra_taxonomy_validations
|
191
|
-
# Use extra validations on Taxonomies in 3.4.0, but default to false so stores can
|
192
|
-
# upgrade and then fix any now invalid Taxonomies before enabling.
|
193
|
-
# @return [Boolean]
|
194
|
-
versioned_preference :extra_taxonomy_validations, :boolean, initial_value: false, boundaries: { "3.4.0.dev" => true }
|
195
|
-
def extra_taxonomy_validations=(value)
|
196
|
-
Spree::Deprecation.warn <<~MSG
|
197
|
-
Solidus will remove `Spree::Config.extra_taxonomy_validations` preference
|
198
|
-
in the next major release and will always use the extra Taxonomy validations.
|
199
|
-
Before upgrading to the next major, please fix any now invalid Taxons
|
200
|
-
and then remove the preference definition in `config/initializers/spree.rb`.
|
201
|
-
MSG
|
202
|
-
|
203
|
-
preferences[:extra_taxonomy_validations] = value
|
204
|
-
end
|
205
|
-
|
206
152
|
# @!attribute [rw] generate_api_key_for_all_roles
|
207
153
|
# @return [Boolean] Allow generating api key automatically for user
|
208
154
|
# at role_user creation for all roles. (default: +false+)
|
@@ -239,20 +185,6 @@ module Spree
|
|
239
185
|
# entity expansion attacks.
|
240
186
|
preference :log_entry_allow_aliases, :boolean, default: true
|
241
187
|
|
242
|
-
# @!attribute [rw] mails_from
|
243
|
-
# @return [String] Email address used as +From:+ field in transactional emails.
|
244
|
-
# @deprecated Spree::Store#mail_from_address is used instead
|
245
|
-
preference :mails_from, :string, default: 'solidus@example.com'
|
246
|
-
def mails_from=(value)
|
247
|
-
Spree::Deprecation.warn(<<~MSG) && preferences[:mail_from] = value
|
248
|
-
Solidus doesn't use `Spree::Config.mails_from` preference and it'll
|
249
|
-
removed on the next major release. Please, remove its definition in
|
250
|
-
`config/initializers/spree.rb`. Use the `Spree::Store#mail_from_address`
|
251
|
-
attribute for the default email address used as the 'From:' field in
|
252
|
-
transactional emails.
|
253
|
-
MSG
|
254
|
-
end
|
255
|
-
|
256
188
|
# @!attribute [rw] max_level_in_taxons_menu
|
257
189
|
# @return [Integer] maximum nesting level in taxons menu (default: +1+)
|
258
190
|
preference :max_level_in_taxons_menu, :integer, default: 1
|
@@ -347,14 +279,6 @@ module Spree
|
|
347
279
|
# @return [] Track on_hand values for variants / products. (default: true)
|
348
280
|
preference :track_inventory_levels, :boolean, default: true
|
349
281
|
|
350
|
-
# @!attribute [rw] use_legacy_events
|
351
|
-
# Before v3.2, Solidus used a custom pub/sub implementation based on
|
352
|
-
# ActiveSupport::Notifications. Now, we internally use and recommend
|
353
|
-
# [Omnes](https://github.com/nebulab/omnes). This preference allows falling
|
354
|
-
# back to the old system.
|
355
|
-
# @return [Boolean]
|
356
|
-
versioned_preference :use_legacy_events, :boolean, initial_value: true, boundaries: { "3.2.0.alpha" => false }
|
357
|
-
|
358
282
|
# Other configurations
|
359
283
|
|
360
284
|
# Allows restricting what currencies will be available.
|
@@ -433,6 +357,14 @@ module Spree
|
|
433
357
|
# with the same signature as Spree::OrderUpdateAttributes.
|
434
358
|
class_name_attribute :order_update_attributes_class, default: 'Spree::OrderUpdateAttributes'
|
435
359
|
|
360
|
+
# Allows providing a different order recalculator.
|
361
|
+
# @!attribute [rw] order_recalculator_class
|
362
|
+
# @see Spree::OrderUpdater
|
363
|
+
# @return [Class] an object that conforms to the API of
|
364
|
+
# the standard order recalculator class
|
365
|
+
# Spree::OrderUpdater.
|
366
|
+
class_name_attribute :order_recalculator_class, default: 'Spree::OrderUpdater'
|
367
|
+
|
436
368
|
# Allows providing your own Mailer for promotion code batch mailer.
|
437
369
|
#
|
438
370
|
# @!attribute [rw] promotion_code_batch_mailer_class
|
@@ -566,7 +498,7 @@ module Spree
|
|
566
498
|
# @!attribute [rw] image_attachment_module
|
567
499
|
# @return [Module] a module that can be included into Spree::Image to allow attachments
|
568
500
|
# Enumerable of images adhering to the present_image_class interface
|
569
|
-
class_name_attribute :image_attachment_module, default: Spree::
|
501
|
+
class_name_attribute :image_attachment_module, default: "Spree::Image::ActiveStorageAttachment"
|
570
502
|
|
571
503
|
# @!attribute [rw] allowed_image_mime_types
|
572
504
|
#
|
@@ -633,7 +565,7 @@ module Spree
|
|
633
565
|
# @!attribute [rw] taxon_attachment_module
|
634
566
|
# @return [Module] a module that can be included into Spree::Taxon to allow attachments
|
635
567
|
# Enumerable of taxons adhering to the present_taxon_class interface
|
636
|
-
class_name_attribute :taxon_attachment_module, default: Spree::
|
568
|
+
class_name_attribute :taxon_attachment_module, default: "Spree::Taxon::ActiveStorageAttachment"
|
637
569
|
|
638
570
|
# Configures the absolute path that contains the Solidus engine
|
639
571
|
# migrations. This will be checked at app boot to confirm that all Solidus
|
@@ -676,10 +608,6 @@ module Spree
|
|
676
608
|
end
|
677
609
|
end
|
678
610
|
|
679
|
-
def events
|
680
|
-
@events_configuration ||= Spree::Event::Configuration.new
|
681
|
-
end
|
682
|
-
|
683
611
|
def user_last_url_storer_rules
|
684
612
|
@user_last_url_storer_rules ||= ::Spree::Core::ClassConstantizer::Set.new.tap do |set|
|
685
613
|
set << 'Spree::UserLastUrlStorer::Rules::AuthenticationRule'
|
data/lib/spree/bus.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'omnes'
|
2
4
|
|
3
5
|
module Spree
|
@@ -5,16 +7,5 @@ module Spree
|
|
5
7
|
#
|
6
8
|
# This is used for internal events, while host applications are also able to
|
7
9
|
# use it.
|
8
|
-
#
|
9
|
-
# It has some modifications to support internal usage of the legacy event
|
10
|
-
# system {see Spree::AppConfiguration#use_legacy_events}.
|
11
10
|
Bus = Omnes::Bus.new
|
12
|
-
def Bus.publish(event, **kwargs)
|
13
|
-
if Spree::Config.use_legacy_events
|
14
|
-
Spree::Event.fire(event, **kwargs)
|
15
|
-
else
|
16
|
-
# Override caller_location to point to the actual event publisher
|
17
|
-
super(event, **kwargs, caller_location: caller_locations(1)[0])
|
18
|
-
end
|
19
|
-
end
|
20
11
|
end
|
@@ -17,7 +17,6 @@ module Spree
|
|
17
17
|
|
18
18
|
included do
|
19
19
|
before_action :set_guest_token
|
20
|
-
helper_method :try_spree_current_user
|
21
20
|
helper_method :spree_current_user
|
22
21
|
|
23
22
|
class_attribute :unauthorized_redirect
|
@@ -58,21 +57,6 @@ module Spree
|
|
58
57
|
def spree_current_user
|
59
58
|
defined?(super) ? super : nil
|
60
59
|
end
|
61
|
-
|
62
|
-
# proxy method to *possible* spree_current_user method
|
63
|
-
# Authentication extensions (such as spree_auth_devise) are meant to provide spree_current_user
|
64
|
-
def try_spree_current_user
|
65
|
-
# This one will be defined by apps looking to hook into Spree
|
66
|
-
# As per authentication_helpers.rb
|
67
|
-
if respond_to?(:spree_current_user, true)
|
68
|
-
spree_current_user
|
69
|
-
# This one will be defined by Devise
|
70
|
-
elsif respond_to?(:current_spree_user, true)
|
71
|
-
current_spree_user
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
deprecate try_spree_current_user: :spree_current_user, deprecator: Spree::Deprecation
|
76
60
|
end
|
77
61
|
end
|
78
62
|
end
|
data/lib/spree/core/engine.rb
CHANGED
@@ -52,27 +52,17 @@ module Spree
|
|
52
52
|
|
53
53
|
# Setup pub/sub
|
54
54
|
initializer 'spree.core.pub_sub' do |app|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
%i[
|
68
|
-
order_finalized
|
69
|
-
order_recalculated
|
70
|
-
reimbursement_reimbursed
|
71
|
-
reimbursement_errored
|
72
|
-
].each { |event_name| Spree::Bus.register(event_name) }
|
73
|
-
|
74
|
-
Spree::OrderMailerSubscriber.new.subscribe_to(Spree::Bus)
|
75
|
-
end
|
55
|
+
app.reloader.to_prepare do
|
56
|
+
Spree::Bus.clear
|
57
|
+
|
58
|
+
%i[
|
59
|
+
order_finalized
|
60
|
+
order_recalculated
|
61
|
+
reimbursement_reimbursed
|
62
|
+
reimbursement_errored
|
63
|
+
].each { |event_name| Spree::Bus.register(event_name) }
|
64
|
+
|
65
|
+
Spree::OrderMailerSubscriber.new.subscribe_to(Spree::Bus)
|
76
66
|
end
|
77
67
|
end
|
78
68
|
|
@@ -97,16 +87,6 @@ module Spree
|
|
97
87
|
Spree::UsersController.protect_from_forgery with: :exception
|
98
88
|
end
|
99
89
|
end
|
100
|
-
|
101
|
-
config.after_initialize do
|
102
|
-
if Spree::Config.use_legacy_events && !ENV['CI']
|
103
|
-
Spree::Deprecation.warn <<~MSG
|
104
|
-
Your Solidus store is using the legacy event system. You're
|
105
|
-
encouraged to switch to the new event bus. After you're done, you
|
106
|
-
can remove the `use_legacy_events` setting from `spree.rb`.
|
107
|
-
MSG
|
108
|
-
end
|
109
|
-
end
|
110
90
|
end
|
111
91
|
end
|
112
92
|
end
|
@@ -40,7 +40,7 @@ module Spree
|
|
40
40
|
end
|
41
41
|
|
42
42
|
# Really ensure that the order totals & states are correct
|
43
|
-
order.
|
43
|
+
order.recalculate
|
44
44
|
if shipments_attrs.present?
|
45
45
|
order.shipments.each_with_index do |shipment, index|
|
46
46
|
shipment.update_columns(cost: shipments_attrs[index][:cost].to_f) if shipments_attrs[index][:cost].present?
|
@@ -12,10 +12,6 @@ module Spree
|
|
12
12
|
# end
|
13
13
|
#
|
14
14
|
class EmailValidator < ActiveModel::EachValidator
|
15
|
-
EMAIL_REGEXP = URI::MailTo::EMAIL_REGEXP
|
16
|
-
# Use Spree::Config.default_email_regexp instead
|
17
|
-
deprecate_constant :EMAIL_REGEXP
|
18
|
-
|
19
15
|
def validate_each(record, attribute, value)
|
20
16
|
unless Spree::Config.default_email_regexp.match? value
|
21
17
|
record.errors.add(attribute, :invalid, **{ value: value }.merge!(options))
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
@@ -20,7 +20,6 @@ require 'ransack'
|
|
20
20
|
require 'state_machines-activerecord'
|
21
21
|
|
22
22
|
require 'spree/deprecation'
|
23
|
-
require 'spree/rails_compatibility'
|
24
23
|
|
25
24
|
# This is required because ActiveModel::Validations#invalid? conflicts with the
|
26
25
|
# invalid state of a Payment. In the future this should be removed.
|
@@ -94,7 +93,6 @@ require 'spree/core/environment/promotions'
|
|
94
93
|
require 'spree/core/environment'
|
95
94
|
require 'spree/migrations'
|
96
95
|
require 'spree/migration_helpers'
|
97
|
-
require 'spree/event'
|
98
96
|
require 'spree/bus'
|
99
97
|
require 'spree/core/engine'
|
100
98
|
|
@@ -6,9 +6,9 @@ module Spree
|
|
6
6
|
remove_index(table, column) if index_exists?(table, column)
|
7
7
|
end
|
8
8
|
|
9
|
-
def safe_add_index(table, column, options
|
10
|
-
if columns_exist?(table, column) && !index_exists?(table, column, options)
|
11
|
-
add_index(table, column, options)
|
9
|
+
def safe_add_index(table, column, **options)
|
10
|
+
if columns_exist?(table, column) && !index_exists?(table, column, **options)
|
11
|
+
add_index(table, column, **options)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -2,9 +2,27 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Read-only permissions for e-commerce settings.
|
6
|
+
#
|
7
|
+
# Roles with this permission will be able to view information, also from the admin
|
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
|
5
24
|
class ConfigurationDisplay < PermissionSets::Base
|
6
25
|
def activate!
|
7
|
-
can [:edit, :admin], :general_settings
|
8
26
|
can [:read, :admin], Spree::TaxCategory
|
9
27
|
can [:read, :admin], Spree::TaxRate
|
10
28
|
can [:read, :admin], Spree::Zone
|
@@ -2,9 +2,26 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Read and write permissions for e-commerce settings.
|
6
|
+
#
|
7
|
+
# Roles with this permission set will have full control over:
|
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
|
5
23
|
class ConfigurationManagement < PermissionSets::Base
|
6
24
|
def activate!
|
7
|
-
can :manage, :general_settings
|
8
25
|
can :manage, Spree::TaxCategory
|
9
26
|
can :manage, Spree::TaxRate
|
10
27
|
can :manage, Spree::Zone
|
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Permissions for viewing the admin dashboard.
|
6
|
+
#
|
7
|
+
# Roles with this permission set will be able to view the admin dashboard,
|
8
|
+
# which may or not contain sensitive information depending on
|
9
|
+
# customizations.
|
5
10
|
class DashboardDisplay < PermissionSets::Base
|
6
11
|
def activate!
|
7
12
|
can [:admin, :home], :dashboards
|
@@ -2,6 +2,35 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Permissions for e-commerce customers.
|
6
|
+
#
|
7
|
+
# This permission set is always added to the `:default` role, which in turn
|
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.
|
5
34
|
class DefaultCustomer < PermissionSets::Base
|
6
35
|
def activate!
|
7
36
|
can :read, Country
|
@@ -2,6 +2,25 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Read permissions for orders.
|
6
|
+
#
|
7
|
+
# This permission set allows users to view all related information about
|
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.
|
5
24
|
class OrderDisplay < PermissionSets::Base
|
6
25
|
def activate!
|
7
26
|
can [:read, :admin, :edit, :cart], Spree::Order
|
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Full permissions for order management.
|
6
|
+
#
|
7
|
+
# This permission set grants full control over all order and related resources,
|
8
|
+
# 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
|
+
# It also allows reading reimbursement types, but not modifying them.
|
5
23
|
class OrderManagement < PermissionSets::Base
|
6
24
|
def activate!
|
7
25
|
can :read, Spree::ReimbursementType
|
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Read-only permissions for products.
|
6
|
+
#
|
7
|
+
# This permission set allows users to view all related information about
|
8
|
+
# products, also from the admin panel, including:
|
9
|
+
#
|
10
|
+
# - Products
|
11
|
+
# - Images
|
12
|
+
# - Variants
|
13
|
+
# - Option values
|
14
|
+
# - Product properties
|
15
|
+
# - Option types
|
16
|
+
# - Properties
|
17
|
+
# - Taxonomies
|
18
|
+
# - Taxons
|
5
19
|
class ProductDisplay < PermissionSets::Base
|
6
20
|
def activate!
|
7
21
|
can [:read, :admin, :edit], Spree::Product
|
@@ -2,6 +2,22 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Full permissions for product management.
|
6
|
+
#
|
7
|
+
# This permission set grants full control over all product and related resources,
|
8
|
+
# including:
|
9
|
+
#
|
10
|
+
# - Products
|
11
|
+
# - Images
|
12
|
+
# - Variants
|
13
|
+
# - Option values
|
14
|
+
# - Product properties
|
15
|
+
# - Option types
|
16
|
+
# - Properties
|
17
|
+
# - Taxonomies
|
18
|
+
# - Taxons
|
19
|
+
# - Classifications
|
20
|
+
# - Prices
|
5
21
|
class ProductManagement < PermissionSets::Base
|
6
22
|
def activate!
|
7
23
|
can :manage, Spree::Classification
|
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Read-only permissions for promotions.
|
6
|
+
#
|
7
|
+
# This permission set allows users to view all related information about
|
8
|
+
# promotions, also from the admin panel, including:
|
9
|
+
#
|
10
|
+
# - Promotions
|
11
|
+
# - Promotion rules
|
12
|
+
# - Promotion actions
|
13
|
+
# - Promotion categories
|
14
|
+
# - Promotion codes
|
5
15
|
class PromotionDisplay < PermissionSets::Base
|
6
16
|
def activate!
|
7
17
|
can [:read, :admin, :edit], Spree::Promotion
|
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Full permissions for promotion management.
|
6
|
+
#
|
7
|
+
# This permission set grants full control over all promotion and related resources,
|
8
|
+
# including:
|
9
|
+
#
|
10
|
+
# - Promotions
|
11
|
+
# - Promotion rules
|
12
|
+
# - Promotion actions
|
13
|
+
# - Promotion categories
|
14
|
+
# - Promotion codes
|
5
15
|
class PromotionManagement < PermissionSets::Base
|
6
16
|
def activate!
|
7
17
|
can :manage, Spree::Promotion
|
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Read permissions for stock limited to allowed locations.
|
6
|
+
#
|
7
|
+
# This permission set allows users to view information about stock items and
|
8
|
+
# locations, both of them limited to locations they have access to.
|
9
|
+
# Permissions are also granted for the admin panel for items.
|
5
10
|
class RestrictedStockDisplay < PermissionSets::Base
|
6
11
|
def activate!
|
7
12
|
can [:read, :admin], Spree::StockItem, stock_location_id: location_ids
|
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Full permissions for stock management limited to allowed locations.
|
6
|
+
#
|
7
|
+
# This permission set grants full control over all stock items a user has
|
8
|
+
# access to their locations. Those locations are also readable by the
|
9
|
+
# corresponding ability.
|
5
10
|
class RestrictedStockManagement < PermissionSets::Base
|
6
11
|
def activate!
|
7
12
|
can :manage, Spree::StockItem, stock_location_id: location_ids
|
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Read-only permissions for stock.
|
6
|
+
#
|
7
|
+
# This permission set allows users to view information about stock items
|
8
|
+
# (also from the admin panel) and stock locations.
|
5
9
|
class StockDisplay < PermissionSets::Base
|
6
10
|
def activate!
|
7
11
|
can [:read, :admin], Spree::StockItem
|
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Full permissions for stock management.
|
6
|
+
#
|
7
|
+
# This permission set grants full control over all stock items and read
|
8
|
+
# access to locations.
|
5
9
|
class StockManagement < PermissionSets::Base
|
6
10
|
def activate!
|
7
11
|
can :manage, Spree::StockItem
|
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Full permissions for store administration.
|
6
|
+
#
|
7
|
+
# This permission set is always added to users with the `:admin` role.
|
8
|
+
#
|
9
|
+
# It grants permission to perform any read or write action on any resource.
|
5
10
|
class SuperUser < PermissionSets::Base
|
6
11
|
def activate!
|
7
12
|
can :manage, :all
|
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Read-only permissions for users, roles and store credits.
|
6
|
+
#
|
7
|
+
# This permission set allows users to view all related information about
|
8
|
+
# users, roles and store credits, also from the admin panel.
|
5
9
|
class UserDisplay < PermissionSets::Base
|
6
10
|
def activate!
|
7
11
|
can [:read, :admin, :edit, :addresses, :orders, :items], Spree.user_class
|
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module PermissionSets
|
5
|
+
# Full permissions for user management.
|
6
|
+
#
|
7
|
+
# This permission set grants full control over all user and
|
8
|
+
# related resources, including:
|
9
|
+
#
|
10
|
+
# - Users
|
11
|
+
# - Store credits
|
12
|
+
# - Roles
|
13
|
+
# - API keys
|
5
14
|
class UserManagement < PermissionSets::Base
|
6
15
|
def activate!
|
7
16
|
can [:admin, :read, :create, :update, :save_in_address_book, :remove_from_address_book, :addresses, :orders, :items], Spree.user_class
|