solidus_core 2.11.10 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -2
- data/app/assets/javascripts/spree.js.erb +0 -51
- data/app/controllers/spree/base_controller.rb +1 -1
- data/app/helpers/spree/base_helper.rb +1 -1
- data/app/helpers/spree/products_helper.rb +2 -2
- data/app/helpers/spree/store_helper.rb +0 -11
- data/app/mailers/spree/carton_mailer.rb +1 -5
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +30 -11
- data/app/models/concerns/spree/active_storage_adapter.rb +1 -1
- data/app/models/concerns/spree/adjustment_source.rb +0 -15
- data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
- data/app/models/concerns/spree/default_price.rb +39 -10
- data/app/models/concerns/spree/ransackable_attributes.rb +24 -4
- data/app/models/concerns/spree/soft_deletable.rb +2 -4
- data/app/models/concerns/spree/user_address_book.rb +10 -37
- data/app/models/concerns/spree/user_methods.rb +38 -13
- data/app/models/spree/ability.rb +0 -37
- data/app/models/spree/address/name.rb +2 -20
- data/app/models/spree/address.rb +8 -186
- data/app/models/spree/adjustment.rb +7 -33
- data/app/models/spree/base.rb +0 -53
- data/app/models/spree/calculator/flat_fee.rb +21 -0
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- data/app/models/spree/calculator.rb +0 -7
- data/app/models/spree/carton.rb +1 -1
- data/app/models/spree/country.rb +2 -7
- data/app/models/spree/credit_card.rb +1 -28
- data/app/models/spree/customer_return.rb +5 -7
- data/app/models/spree/image/active_storage_attachment.rb +2 -7
- data/app/models/spree/image/paperclip_attachment.rb +2 -2
- data/app/models/spree/image.rb +0 -7
- data/app/models/spree/inventory_unit.rb +0 -21
- data/app/models/spree/line_item.rb +6 -49
- data/app/models/spree/log_entry.rb +74 -1
- data/app/models/spree/option_type.rb +1 -1
- data/app/models/spree/option_value.rb +10 -1
- data/app/models/spree/order/number_generator.rb +7 -1
- data/app/models/spree/order.rb +82 -170
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_contents.rb +2 -1
- data/app/models/spree/order_inventory.rb +1 -1
- data/app/models/spree/order_merger.rb +2 -2
- data/app/models/spree/order_promotion.rb +1 -1
- data/app/models/spree/order_shipping.rb +6 -9
- data/app/models/spree/order_taxation.rb +6 -4
- data/app/models/spree/order_updater.rb +17 -16
- data/app/models/spree/payment/cancellation.rb +1 -1
- data/app/models/spree/payment/processing.rb +58 -55
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method/bogus_credit_card.rb +6 -7
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +8 -0
- data/app/models/spree/payment_method.rb +26 -110
- data/app/models/spree/price.rb +3 -3
- data/app/models/spree/product/scopes.rb +24 -33
- data/app/models/spree/product.rb +15 -42
- data/app/models/spree/product_property.rb +1 -1
- data/app/models/spree/promotion/actions/create_adjustment.rb +4 -3
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +5 -9
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -0
- data/app/models/spree/promotion/order_adjustments_recalculator.rb +92 -0
- data/app/models/spree/promotion/rules/item_total.rb +50 -6
- data/app/models/spree/promotion/rules/product.rb +20 -8
- data/app/models/spree/promotion/rules/store.rb +4 -0
- data/app/models/spree/promotion/rules/taxon.rb +6 -15
- data/app/models/spree/promotion/rules/user.rb +4 -0
- data/app/models/spree/promotion.rb +39 -32
- data/app/models/spree/promotion_action.rb +6 -9
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/promotion_code.rb +11 -7
- data/app/models/spree/promotion_handler/cart.rb +26 -6
- data/app/models/spree/promotion_rule.rb +5 -0
- data/app/models/spree/property.rb +1 -1
- data/app/models/spree/refund.rb +8 -52
- data/app/models/spree/reimbursement.rb +5 -43
- data/app/models/spree/reimbursement_performer.rb +2 -8
- data/app/models/spree/reimbursement_type/credit.rb +1 -4
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
- data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
- data/app/models/spree/return_authorization.rb +2 -5
- data/app/models/spree/return_item.rb +4 -24
- data/app/models/spree/shipment.rb +3 -56
- data/app/models/spree/shipping_method.rb +0 -25
- data/app/models/spree/shipping_rate.rb +0 -2
- data/app/models/spree/shipping_rate_tax.rb +1 -1
- data/app/models/spree/state.rb +1 -5
- data/app/models/spree/stock/allocator/on_hand_first.rb +2 -2
- data/app/models/spree/stock/availability.rb +11 -3
- data/app/models/spree/stock/quantifier.rb +12 -8
- data/app/models/spree/stock/simple_coordinator.rb +8 -26
- data/app/models/spree/stock/splitter/base.rb +2 -7
- data/app/models/spree/stock_item.rb +2 -8
- data/app/models/spree/stock_location.rb +2 -2
- data/app/models/spree/stock_movement.rb +2 -2
- data/app/models/spree/store.rb +0 -12
- data/app/models/spree/store_credit.rb +14 -1
- data/app/models/spree/store_credit_category.rb +0 -32
- data/app/models/spree/store_credit_prioritizer.rb +17 -0
- data/app/models/spree/tax/item_tax.rb +3 -2
- data/app/models/spree/tax/order_tax.rb +3 -1
- data/app/models/spree/tax/tax_helpers.rb +2 -2
- data/app/models/spree/tax/tax_location.rb +4 -7
- data/app/models/spree/tax_calculator/default.rb +31 -0
- data/app/models/spree/tax_calculator/shipping_rate.rb +2 -13
- data/app/models/spree/tax_rate.rb +9 -27
- data/app/models/spree/taxon/active_storage_attachment.rb +2 -7
- data/app/models/spree/taxon/paperclip_attachment.rb +3 -8
- data/app/models/spree/taxon.rb +1 -12
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/user_address.rb +0 -5
- data/app/models/spree/user_last_url_storer/rules/authentication_rule.rb +1 -1
- data/app/models/spree/variant/price_selector.rb +34 -4
- data/app/models/spree/variant.rb +52 -66
- data/app/models/spree/zone.rb +1 -1
- data/app/subscribers/spree/mailer_subscriber.rb +4 -0
- data/app/subscribers/spree/order_mailer_subscriber.rb +35 -0
- data/config/i18n-tasks.yml +134 -0
- data/config/locales/en.yml +406 -263
- data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
- data/db/migrate/20201127212108_add_type_before_removal_to_spree_payment_methods.rb +7 -0
- data/db/migrate/20210312061050_change_column_null_on_prices.rb +7 -0
- data/db/migrate/20220317165036_set_promotions_with_any_policy_to_all_if_possible.rb +20 -0
- data/db/migrate/20220805202442_add_level_to_spree_tax_rates.rb +5 -0
- data/db/migrate/20221123152807_add_shipping_category_to_spree_variants.rb +5 -0
- data/db/seeds.rb +4 -1
- data/lib/generators/solidus/install/app_templates/authentication/custom.rb +21 -0
- data/lib/generators/solidus/install/app_templates/authentication/devise.rb +16 -0
- data/lib/generators/solidus/install/app_templates/authentication/existing.rb +10 -0
- data/lib/generators/solidus/install/app_templates/authentication/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/frontend/break_down_solidus_gem.rb +54 -0
- data/lib/generators/solidus/install/app_templates/frontend/classic.rb +16 -0
- data/lib/generators/solidus/install/app_templates/frontend/none.rb +2 -0
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +3 -0
- data/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +13 -0
- data/lib/generators/solidus/install/app_templates/payment_method/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +10 -0
- data/lib/generators/solidus/install/install_generator.rb +247 -149
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +15 -60
- data/lib/generators/solidus/install/templates/vendor/assets/javascripts/spree/backend/all.js +2 -2
- data/lib/generators/solidus/update/templates/config/initializers/new_solidus_defaults.rb.tt +30 -0
- data/lib/generators/solidus/update/update_generator.rb +112 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +6 -4
- data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +2 -6
- data/lib/generators/spree/custom_user/templates/migration.rb.tt +7 -3
- data/lib/generators/spree/dummy/dummy_generator.rb +12 -9
- data/lib/generators/spree/dummy/templates/rails/application.rb.tt +0 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +81 -39
- data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
- data/lib/spree/app_configuration.rb +134 -64
- data/lib/spree/bus.rb +20 -0
- data/lib/spree/core/class_constantizer.rb +2 -0
- data/lib/spree/core/controller_helpers/auth.rb +10 -15
- data/lib/spree/core/controller_helpers/current_host.rb +5 -3
- data/lib/spree/core/controller_helpers/order.rb +12 -32
- data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
- data/lib/spree/core/controller_helpers/pricing.rb +0 -8
- data/lib/spree/core/controller_helpers/search.rb +1 -1
- data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
- data/lib/spree/core/engine.rb +54 -50
- data/lib/spree/core/environment_extension.rb +0 -9
- data/lib/spree/core/product_filters.rb +1 -41
- data/lib/spree/core/role_configuration.rb +0 -14
- data/lib/spree/core/search/base.rb +18 -35
- data/lib/spree/core/state_machines/order.rb +2 -2
- data/lib/spree/core/state_machines.rb +2 -11
- data/lib/spree/core/stock_configuration.rb +18 -0
- data/lib/spree/core/validators/email.rb +5 -3
- data/lib/spree/core/version.rb +5 -1
- data/lib/spree/core/versioned_value.rb +75 -0
- data/lib/spree/core.rb +40 -11
- data/lib/spree/deprecation.rb +1 -1
- data/lib/spree/event/configuration.rb +0 -5
- data/lib/spree/event/subscriber.rb +0 -18
- data/lib/spree/event/subscriber_registry.rb +7 -7
- data/lib/spree/event.rb +1 -32
- data/lib/spree/i18n.rb +0 -22
- data/lib/spree/migrations.rb +13 -11
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permission_sets/default_customer.rb +8 -1
- data/lib/spree/permitted_attributes.rb +17 -59
- data/lib/spree/preferences/configuration.rb +84 -0
- data/lib/spree/preferences/preferable.rb +13 -0
- data/lib/spree/preferences/preferable_class_methods.rb +37 -4
- data/lib/spree/preferences/preference_differentiator.rb +29 -0
- data/lib/spree/preferences/static_model_preferences.rb +25 -10
- data/lib/spree/rails_compatibility.rb +106 -0
- data/lib/spree/testing_support/blacklist_urls.rb +1 -1
- data/lib/spree/testing_support/bus_helpers.rb +101 -0
- data/lib/spree/testing_support/capybara_ext.rb +0 -30
- data/lib/spree/testing_support/common_rake.rb +71 -23
- data/lib/spree/testing_support/controller_requests.rb +0 -82
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/backend/all.js +1 -1
- data/lib/spree/testing_support/dummy_app/assets/javascripts/spree/frontend/all.js +1 -1
- data/lib/spree/testing_support/dummy_app/database.yml +42 -22
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- data/lib/spree/testing_support/dummy_app.rb +47 -34
- data/lib/spree/testing_support/factories/address_factory.rb +9 -6
- data/lib/spree/testing_support/factories/calculator_factory.rb +3 -0
- data/lib/spree/testing_support/factories/country_factory.rb +1 -2
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +8 -5
- data/lib/spree/testing_support/factories/product_factory.rb +4 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +28 -14
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
- data/lib/spree/testing_support/factories/state_factory.rb +8 -2
- data/lib/spree/testing_support/factories/store_credit_factory.rb +4 -4
- data/lib/spree/testing_support/factories/user_factory.rb +6 -0
- data/lib/spree/testing_support/factory_bot.rb +2 -2
- data/lib/spree/testing_support/order_walkthrough.rb +6 -8
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/spree/testing_support/silence_deprecations.rb +9 -0
- data/lib/tasks/colorado_delivery_fee.rake +28 -0
- data/lib/tasks/payment_method.rake +29 -0
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +18 -0
- data/lib/tasks/solidus/delete_prices_with_nil_amount.rake +8 -0
- data/lib/tasks/solidus/split_promotions_with_any_match_policy.rake +33 -0
- data/solidus_core.gemspec +14 -7
- metadata +127 -78
- data/app/mailers/spree/test_mailer.rb +0 -13
- data/app/models/concerns/spree/user_payment_source.rb +0 -26
- data/app/models/spree/calculator/free_shipping.rb +0 -22
- data/app/models/spree/calculator/percent_per_item.rb +0 -51
- data/app/models/spree/calculator/price_sack.rb +0 -28
- data/app/models/spree/gateway/bogus.rb +0 -13
- data/app/models/spree/gateway/bogus_simple.rb +0 -13
- data/app/models/spree/gateway.rb +0 -14
- data/app/models/spree/order/checkout.rb +0 -244
- data/app/models/spree/order_capturing.rb +0 -50
- data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
- data/app/models/spree/tax/shipping_rate_taxer.rb +0 -24
- data/lib/generators/solidus/install/templates/vendor/assets/javascripts/spree/frontend/all.js +0 -10
- data/lib/generators/solidus/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +0 -9
- data/lib/generators/spree/install/install_generator.rb +0 -15
- data/lib/solidus/migrations/rename_gateways.rb +0 -41
- data/lib/spree/core/current_store.rb +0 -24
- data/lib/spree/paranoia_deprecations.rb +0 -41
- data/lib/spree/promo/environment.rb +0 -12
- data/lib/spree/testing_support/bar_ability.rb +0 -19
- data/lib/tasks/core.rake +0 -104
- data/lib/tasks/email.rake +0 -12
- data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
- data/lib/tasks/migrations/migrate_address_names.rake +0 -158
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +0 -26
- data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
- data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
- data/lib/tasks/migrations/rename_gateways.rake +0 -23
- data/lib/tasks/order_capturing.rake +0 -27
- data/lib/tasks/upgrade.rake +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41166c504ad4a467ac0d444551669efca2f6ff36b8083b11483ca1d6953c838e
|
4
|
+
data.tar.gz: f9c8abd6767eb3aaecf807d1e360defbb57ba7af0590d88b6019f0cd8bf2f1b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f9384ee4d463107d31e2cff1670ee587e7c2ad61795f11d1120bb69049fcc0bec3f04a0edee1e10e4c951a5b287cd9b93986c4194b87303e1a2a1ee38a7062a
|
7
|
+
data.tar.gz: 6d924bbc21a024712b1579c6bb73390904b456fc4671f1dc15b17de255d2f543b7cdcd2a4484e005444be085041a98819c6b3d2a1d55469305ce5b85108327e3
|
data/Rakefile
CHANGED
@@ -14,8 +14,12 @@ DummyApp::RakeTasks.new(
|
|
14
14
|
lib_name: 'solidus_core'
|
15
15
|
)
|
16
16
|
|
17
|
-
require 'yard'
|
18
|
-
YARD::Rake::YardocTask.new
|
17
|
+
require 'yard/rake/yardoc_task'
|
18
|
+
YARD::Rake::YardocTask.new(:yard)
|
19
|
+
# The following workaround can be removed
|
20
|
+
# once https://github.com/lsegal/yard/pull/1457 is merged.
|
21
|
+
task('yard:require') { require 'yard' }
|
22
|
+
task yard: 'yard:require'
|
19
23
|
|
20
24
|
namespace :spec do
|
21
25
|
task :isolated do
|
@@ -22,21 +22,6 @@ Spree.pathFor = function(path) {
|
|
22
22
|
return locationOrigin + Spree.mountedAt() + path;
|
23
23
|
};
|
24
24
|
|
25
|
-
Spree.url = function(uri, query) {
|
26
|
-
if (console && console.warn) {
|
27
|
-
console.warn('Spree.url is deprecated, and will be removed from a future Solidus version.');
|
28
|
-
}
|
29
|
-
if (uri.path === undefined) {
|
30
|
-
uri = new Uri(uri);
|
31
|
-
}
|
32
|
-
if (query) {
|
33
|
-
$.each(query, function(key, value) {
|
34
|
-
return uri.addQueryParam(key, value);
|
35
|
-
});
|
36
|
-
}
|
37
|
-
return uri;
|
38
|
-
};
|
39
|
-
|
40
25
|
Spree.ajax = function(url, options) {
|
41
26
|
if (typeof url === "object") {
|
42
27
|
options = url;
|
@@ -51,42 +36,6 @@ Spree.ajax = function(url, options) {
|
|
51
36
|
return $.ajax(url, options);
|
52
37
|
};
|
53
38
|
|
54
|
-
/**
|
55
|
-
* @deprecated Spree.routes will be removed in a future release. Please use Spree.pathFor instead.
|
56
|
-
* See: https://github.com/solidusio/solidus/issues/3405
|
57
|
-
*/
|
58
|
-
Spree.routesDeprecationProxy = {
|
59
|
-
get: function(obj, prop) {
|
60
|
-
<% if Rails.env != "production" %>
|
61
|
-
console.log("Spree.routes is deprecated, please use pathFor instead. See: https://github.com/solidusio/solidus/issues/3405");
|
62
|
-
<% end %>
|
63
|
-
|
64
|
-
return obj[prop]
|
65
|
-
},
|
66
|
-
|
67
|
-
set: function(obj, prop, value) {
|
68
|
-
<% if Rails.env != "production" %>
|
69
|
-
console.log("Spree.routes is deprecated, please use pathFor instead. See: https://github.com/solidusio/solidus/issues/3405");
|
70
|
-
<% end %>
|
71
|
-
|
72
|
-
obj[prop] = value
|
73
|
-
return value;
|
74
|
-
}
|
75
|
-
};
|
76
|
-
|
77
|
-
var frontend_routes = {
|
78
|
-
states_search: Spree.pathFor('api/states'),
|
79
|
-
apply_coupon_code: function(order_id) {
|
80
|
-
return Spree.pathFor("api/orders/" + order_id + "/coupon_codes");
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
if(typeof Proxy == "function") {
|
85
|
-
Spree.routes = new Proxy(frontend_routes, Spree.routesDeprecationProxy);
|
86
|
-
} else {
|
87
|
-
Spree.routes = frontend_routes
|
88
|
-
}
|
89
|
-
|
90
39
|
Spree.getJSON = function(url, data, success) {
|
91
40
|
if (typeof data === 'function') {
|
92
41
|
success = data;
|
@@ -4,7 +4,7 @@ require 'cancan'
|
|
4
4
|
require_dependency 'spree/core/controller_helpers/strong_parameters'
|
5
5
|
|
6
6
|
class Spree::BaseController < ApplicationController
|
7
|
-
include
|
7
|
+
include ActiveStorage::SetCurrent
|
8
8
|
include Spree::Core::ControllerHelpers::Auth
|
9
9
|
include Spree::Core::ControllerHelpers::Common
|
10
10
|
include Spree::Core::ControllerHelpers::PaymentParameters
|
@@ -130,7 +130,7 @@ module Spree
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def display_price(product_or_variant)
|
133
|
-
product_or_variant.
|
133
|
+
product_or_variant.price_for_options(current_pricing_options)&.money&.to_html
|
134
134
|
end
|
135
135
|
|
136
136
|
def pretty_time(time, format = :long)
|
@@ -38,7 +38,7 @@ module Spree
|
|
38
38
|
.with_prices(current_pricing_options)
|
39
39
|
.all? { |variant_with_prices| variant_with_prices.price_same_as_master?(current_pricing_options) }
|
40
40
|
|
41
|
-
variant.
|
41
|
+
variant.price_for_options(current_pricing_options)&.money&.to_html
|
42
42
|
end
|
43
43
|
|
44
44
|
# Converts line breaks in product description into <p> tags.
|
@@ -68,7 +68,7 @@ module Spree
|
|
68
68
|
# @return [String] a cache invalidation key for products
|
69
69
|
def cache_key_for_products
|
70
70
|
count = @products.count
|
71
|
-
max_updated_at = (@products.maximum(:updated_at) || Date.today)
|
71
|
+
max_updated_at = Spree::RailsCompatibility.to_fs((@products.maximum(:updated_at) || Date.today), :number)
|
72
72
|
"#{I18n.locale}/#{current_pricing_options.cache_key}/spree/products/all-#{params[:page]}-#{max_updated_at}-#{count}"
|
73
73
|
end
|
74
74
|
end
|
@@ -8,16 +8,5 @@ module Spree
|
|
8
8
|
def store_menu?
|
9
9
|
%w{thank_you}.exclude? params[:action]
|
10
10
|
end
|
11
|
-
|
12
|
-
def cache_key_for_taxons
|
13
|
-
Spree::Deprecation.warn <<-WARN.strip_heredoc
|
14
|
-
cache_key_for_taxons is deprecated. Rails >= 5 has built-in support for collection cache keys.
|
15
|
-
Instead in your view use:
|
16
|
-
cache [I18n.locale, @taxons] do
|
17
|
-
WARN
|
18
|
-
max_updated_at = @taxons.maximum(:updated_at).to_i
|
19
|
-
parts = [@taxon.try(:id), max_updated_at].compact.join("-")
|
20
|
-
"#{I18n.locale}/taxons/#{parts}"
|
21
|
-
end
|
22
11
|
end
|
23
12
|
end
|
@@ -11,11 +11,7 @@ module Spree
|
|
11
11
|
# @option options resend [Boolean] indicates whether the email is a 'resend' (e.g.
|
12
12
|
# triggered by the admin "resend" button)
|
13
13
|
# @return [Mail::Message]
|
14
|
-
|
15
|
-
# Note: The signature of this method has changed. The new (non-deprecated)
|
16
|
-
# signature is:
|
17
|
-
# def shipped_email(carton:, order:, resend: false)
|
18
|
-
def shipped_email(options, _deprecated_options = {})
|
14
|
+
def shipped_email(options)
|
19
15
|
@order = options.fetch(:order)
|
20
16
|
@carton = options.fetch(:carton)
|
21
17
|
@manifest = @carton.manifest_for_order(@order)
|
@@ -4,14 +4,16 @@ require 'mini_magick'
|
|
4
4
|
|
5
5
|
module Spree
|
6
6
|
module ActiveStorageAdapter
|
7
|
-
#
|
7
|
+
# Decorates ActiveStorage attachment to add methods expected by Solidus'
|
8
8
|
# Paperclip-oriented attachment support.
|
9
9
|
class Attachment
|
10
10
|
delegate_missing_to :@attachment
|
11
11
|
|
12
|
+
attr_reader :attachment
|
13
|
+
|
12
14
|
def initialize(attachment, styles: {})
|
13
15
|
@attachment = attachment
|
14
|
-
@
|
16
|
+
@transformations = styles_to_transformations(styles)
|
15
17
|
end
|
16
18
|
|
17
19
|
def exists?
|
@@ -27,11 +29,13 @@ module Spree
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def variant(style = nil)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
transformation = @transformations[style] || default_transformation(width, height)
|
33
|
+
|
34
|
+
@attachment.variant({
|
35
|
+
saver: {
|
36
|
+
strip: true
|
37
|
+
}
|
38
|
+
}.merge(transformation)).processed
|
35
39
|
end
|
36
40
|
|
37
41
|
def height
|
@@ -55,14 +59,29 @@ module Spree
|
|
55
59
|
analyze unless analyzed?
|
56
60
|
|
57
61
|
@attachment.metadata
|
62
|
+
rescue ActiveStorage::FileNotFoundError => error
|
63
|
+
logger.error("#{error} - Image id: #{attachment.record.id} is corrupted or cannot be found")
|
64
|
+
|
65
|
+
{ identified: nil, width: nil, height: nil, analyzed: true }
|
58
66
|
end
|
59
67
|
|
60
|
-
def
|
61
|
-
styles.transform_values
|
68
|
+
def styles_to_transformations(styles)
|
69
|
+
styles.transform_values(&method(:imagemagick_to_image_processing_definition))
|
70
|
+
end
|
71
|
+
|
72
|
+
def imagemagick_to_image_processing_definition(definition)
|
73
|
+
width_height = definition.split('x').map(&:to_i)
|
74
|
+
|
75
|
+
case definition[-1].to_sym
|
76
|
+
when :^
|
77
|
+
{ resize_to_fill: width_height }
|
78
|
+
else
|
79
|
+
default_transformation(*width_height)
|
80
|
+
end
|
62
81
|
end
|
63
82
|
|
64
|
-
def
|
65
|
-
|
83
|
+
def default_transformation(width, height)
|
84
|
+
{ resize_to_limit: [width, height] }
|
66
85
|
end
|
67
86
|
end
|
68
87
|
end
|
@@ -10,7 +10,7 @@ module Spree
|
|
10
10
|
included do
|
11
11
|
next if Rails.gem_version >= Gem::Version.new('6.1.0.alpha')
|
12
12
|
|
13
|
-
|
13
|
+
raise <<~MESSAGE
|
14
14
|
Configuration Error: Solidus ActiveStorage attachment adpater requires Rails >= 6.1.0.
|
15
15
|
|
16
16
|
Spree::Config.image_attachment_module preference is set to #{Spree::Config.image_attachment_module}
|
@@ -2,21 +2,6 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
module AdjustmentSource
|
5
|
-
def deals_with_adjustments_for_deleted_source
|
6
|
-
Spree::Deprecation.warn "AdjustmentSource#deals_with_adjustments_for_deleted_source is deprecated. Please use AdjustmentSource#remove_adjustments_from_incomplete_orders instead."
|
7
|
-
|
8
|
-
remove_adjustments_from_incomplete_orders
|
9
|
-
|
10
|
-
# The following is deprecated. As source_type without a source_id isn't
|
11
|
-
# much better than a source_id that doesn't exist. In Solidus itself the
|
12
|
-
# relevant classes use `acts_as_paranoid` so it is useful to keep the
|
13
|
-
# source_id around.
|
14
|
-
adjustments.
|
15
|
-
joins(:order).
|
16
|
-
merge(Spree::Order.complete).
|
17
|
-
update_all(source_id: nil, updated_at: Time.current)
|
18
|
-
end
|
19
|
-
|
20
5
|
def remove_adjustments_from_incomplete_orders
|
21
6
|
adjustments.
|
22
7
|
joins(:order).
|
@@ -10,24 +10,6 @@ module Spree
|
|
10
10
|
validates :calculator, presence: true
|
11
11
|
end
|
12
12
|
|
13
|
-
class_methods do
|
14
|
-
def calculators
|
15
|
-
Spree::Deprecation.warn("Calling .calculators is deprecated. Please access through Rails.application.config.spree.calculators")
|
16
|
-
|
17
|
-
spree_calculators.send model_name_without_spree_namespace
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def model_name_without_spree_namespace
|
23
|
-
to_s.tableize.tr('/', '_').sub('spree_', '')
|
24
|
-
end
|
25
|
-
|
26
|
-
def spree_calculators
|
27
|
-
Spree::Config.environment.calculators
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
13
|
def calculator_type
|
32
14
|
calculator.class.to_s if calculator
|
33
15
|
end
|
@@ -5,20 +5,49 @@ module Spree
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
delegate :display_price, :display_amount, :price, to: :default_price, allow_nil: true
|
9
|
+
delegate :price=, to: :default_price_or_build
|
10
|
+
|
11
|
+
# @see Spree::Variant::PricingOptions.default_price_attributes
|
12
|
+
def self.default_price_attributes
|
13
|
+
Spree::Config.default_pricing_options.desired_attributes
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns `#prices` prioritized for being considered as default price
|
18
|
+
#
|
19
|
+
# @deprecated
|
20
|
+
# @return [ActiveRecord::Relation<Spree::Price>]
|
21
|
+
def currently_valid_prices
|
22
|
+
prices.currently_valid
|
14
23
|
end
|
24
|
+
deprecate :currently_valid_prices, deprecator: Spree::Deprecation
|
15
25
|
|
16
|
-
|
17
|
-
|
26
|
+
# Returns {#default_price} or builds it from {Spree::Variant.default_price_attributes}
|
27
|
+
#
|
28
|
+
# @return [Spree::Price, nil]
|
29
|
+
# @see Spree::Variant.default_price_attributes
|
30
|
+
def default_price_or_build
|
31
|
+
default_price ||
|
32
|
+
prices.build(self.class.default_price_attributes)
|
18
33
|
end
|
19
34
|
|
20
|
-
|
21
|
-
|
35
|
+
# Select from {#prices} the one to be considered as the default
|
36
|
+
#
|
37
|
+
# This method works with the in-memory association, so non-persisted prices
|
38
|
+
# are taken into account.
|
39
|
+
#
|
40
|
+
# A price is a candidate to be considered as the default when it meets
|
41
|
+
# {Spree::Variant.default_price_attributes} criteria. When more than one candidate is
|
42
|
+
# found, non-persisted records take preference. When more than one persisted
|
43
|
+
# candidate exists, the one most recently updated is taken or, in case of
|
44
|
+
# race condition, the one with higher id.
|
45
|
+
#
|
46
|
+
# @return [Spree::Price, nil]
|
47
|
+
# @see Spree::Variant.default_price_attributes
|
48
|
+
def default_price
|
49
|
+
price_selector.price_for_options(Spree::Config.default_pricing_options)
|
50
|
+
end
|
22
51
|
|
23
52
|
def has_default_price?
|
24
53
|
default_price.present? && !default_price.discarded?
|
@@ -3,8 +3,28 @@
|
|
3
3
|
module Spree::RansackableAttributes
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
|
-
class_attribute :
|
7
|
-
class_attribute :
|
6
|
+
class_attribute :allowed_ransackable_associations, default: []
|
7
|
+
class_attribute :allowed_ransackable_attributes, default: []
|
8
|
+
|
9
|
+
def self.whitelisted_ransackable_associations
|
10
|
+
Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_associations, 'use allowed_ransackable_associations instead')
|
11
|
+
allowed_ransackable_associations
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.whitelisted_ransackable_associations=(new_value)
|
15
|
+
Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_associations=, 'use allowed_ransackable_associations= instead')
|
16
|
+
self.allowed_ransackable_associations = new_value
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.whitelisted_ransackable_attributes
|
20
|
+
Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_attributes, 'use allowed_ransackable_attributes instead')
|
21
|
+
allowed_ransackable_attributes
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.whitelisted_ransackable_attributes=(new_value)
|
25
|
+
Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_attributes=, 'use allowed_ransackable_attributes= instead')
|
26
|
+
self.allowed_ransackable_attributes = new_value
|
27
|
+
end
|
8
28
|
|
9
29
|
class_attribute :default_ransackable_attributes
|
10
30
|
self.default_ransackable_attributes = %w[id]
|
@@ -12,11 +32,11 @@ module Spree::RansackableAttributes
|
|
12
32
|
|
13
33
|
class_methods do
|
14
34
|
def ransackable_associations(*_args)
|
15
|
-
|
35
|
+
allowed_ransackable_associations
|
16
36
|
end
|
17
37
|
|
18
38
|
def ransackable_attributes(*_args)
|
19
|
-
default_ransackable_attributes |
|
39
|
+
default_ransackable_attributes | allowed_ransackable_attributes
|
20
40
|
end
|
21
41
|
end
|
22
42
|
end
|
@@ -7,12 +7,10 @@ module Spree
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
acts_as_paranoid
|
11
|
-
include Spree::ParanoiaDeprecations::InstanceMethods
|
12
|
-
extend Spree::ParanoiaDeprecations::ClassMethods
|
13
|
-
|
14
10
|
include Discard::Model
|
15
11
|
self.discard_column = :deleted_at
|
12
|
+
|
13
|
+
default_scope { kept }
|
16
14
|
end
|
17
15
|
end
|
18
16
|
end
|
@@ -37,34 +37,9 @@ module Spree
|
|
37
37
|
|
38
38
|
has_one :default_user_ship_address, ->{ default_shipping }, class_name: 'Spree::UserAddress', foreign_key: 'user_id'
|
39
39
|
has_one :ship_address, through: :default_user_ship_address, source: :address
|
40
|
-
end
|
41
|
-
|
42
|
-
def default_address
|
43
|
-
Spree::Deprecation.warn "#default_address is deprecated. Please start using #ship_address."
|
44
|
-
ship_address
|
45
|
-
end
|
46
|
-
|
47
|
-
def default_user_address
|
48
|
-
Spree::Deprecation.warn "#default_user_address is deprecated. Please start using #default_user_ship_address."
|
49
|
-
default_user_ship_address
|
50
|
-
end
|
51
|
-
|
52
|
-
def default_address=(address)
|
53
|
-
Spree::Deprecation.warn(
|
54
|
-
"#default_address= does not take Spree::Config.automatic_default_address into account and is deprecated. " \
|
55
|
-
"Please use #ship_address=."
|
56
|
-
)
|
57
|
-
|
58
|
-
self.ship_address = address if address
|
59
|
-
end
|
60
|
-
|
61
|
-
def default_address_attributes=(attributes)
|
62
|
-
# see "Nested Attributes Examples" section of http://apidock.com/rails/ActionView/Helpers/FormHelper/fields_for
|
63
|
-
# this #{fieldname}_attributes= method works with fields_for in the views
|
64
|
-
# even without declaring accepts_nested_attributes_for
|
65
|
-
Spree::Deprecation.warn "#default_address_attributes= is deprecated. Please use #ship_address_attributes=."
|
66
40
|
|
67
|
-
|
41
|
+
accepts_nested_attributes_for :ship_address
|
42
|
+
accepts_nested_attributes_for :bill_address
|
68
43
|
end
|
69
44
|
|
70
45
|
# saves address in address book
|
@@ -132,12 +107,19 @@ module Spree
|
|
132
107
|
return new_address unless new_address.valid?
|
133
108
|
|
134
109
|
first_one = user_addresses.empty?
|
110
|
+
user_address = prepare_user_address(new_address)
|
135
111
|
|
136
112
|
if address_attributes[:id].present? && new_address.id != address_attributes[:id]
|
113
|
+
if ship_address&.id == address_attributes[:id].to_i
|
114
|
+
user_addresses.mark_default(user_address, address_type: :shipping)
|
115
|
+
end
|
116
|
+
|
117
|
+
if bill_address&.id == address_attributes[:id].to_i
|
118
|
+
user_addresses.mark_default(user_address, address_type: :billing)
|
119
|
+
end
|
137
120
|
remove_from_address_book(address_attributes[:id])
|
138
121
|
end
|
139
122
|
|
140
|
-
user_address = prepare_user_address(new_address)
|
141
123
|
user_addresses.mark_default(user_address, address_type: address_type) if default || first_one
|
142
124
|
|
143
125
|
if persisted?
|
@@ -157,15 +139,6 @@ module Spree
|
|
157
139
|
user_address.address
|
158
140
|
end
|
159
141
|
|
160
|
-
def mark_default_address(address)
|
161
|
-
Spree::Deprecation.warn(
|
162
|
-
"#mark_default_address is deprecated and it sets the ship_address only. " \
|
163
|
-
"Please use #mark_default_ship_address."
|
164
|
-
)
|
165
|
-
|
166
|
-
mark_default_ship_address(address)
|
167
|
-
end
|
168
|
-
|
169
142
|
def mark_default_ship_address(address)
|
170
143
|
user_addresses.mark_default(user_addresses.find_by(address: address))
|
171
144
|
end
|
@@ -7,7 +7,6 @@ module Spree
|
|
7
7
|
include Spree::UserApiAuthentication
|
8
8
|
include Spree::UserReporting
|
9
9
|
include Spree::UserAddressBook
|
10
|
-
include Spree::UserPaymentSource
|
11
10
|
|
12
11
|
included do
|
13
12
|
extend Spree::DisplayMoney
|
@@ -19,24 +18,22 @@ module Spree
|
|
19
18
|
has_many :stock_locations, through: :user_stock_locations
|
20
19
|
|
21
20
|
has_many :spree_orders, foreign_key: "user_id", class_name: "Spree::Order"
|
22
|
-
has_many :orders, foreign_key: "user_id", class_name: "Spree::Order"
|
21
|
+
has_many :orders, foreign_key: "user_id", class_name: "Spree::Order"
|
23
22
|
|
24
23
|
has_many :store_credits, -> { includes(:credit_type) }, foreign_key: "user_id", class_name: "Spree::StoreCredit"
|
25
24
|
has_many :store_credit_events, through: :store_credits
|
26
25
|
|
27
|
-
money_methods :total_available_store_credit
|
28
|
-
deprecate display_total_available_store_credit: :display_available_store_credit_total, deprecator: Spree::Deprecation
|
29
|
-
|
30
26
|
has_many :credit_cards, class_name: "Spree::CreditCard", foreign_key: :user_id
|
31
27
|
has_many :wallet_payment_sources, foreign_key: 'user_id', class_name: 'Spree::WalletPaymentSource', inverse_of: :user
|
32
28
|
|
33
29
|
after_create :auto_generate_spree_api_key
|
30
|
+
before_destroy :check_for_deletion
|
34
31
|
|
35
32
|
include Spree::RansackableAttributes unless included_modules.include?(Spree::RansackableAttributes)
|
36
33
|
|
37
|
-
ransack_alias :
|
38
|
-
self.
|
39
|
-
self.
|
34
|
+
ransack_alias :name, :addresses_name
|
35
|
+
self.allowed_ransackable_associations = %w[addresses spree_roles]
|
36
|
+
self.allowed_ransackable_attributes = %w[name id email created_at]
|
40
37
|
end
|
41
38
|
|
42
39
|
def wallet
|
@@ -68,11 +65,6 @@ module Spree
|
|
68
65
|
last_order unless last_order.try!(:completed?)
|
69
66
|
end
|
70
67
|
|
71
|
-
def total_available_store_credit
|
72
|
-
store_credits.reload.to_a.sum(&:amount_remaining)
|
73
|
-
end
|
74
|
-
deprecate total_available_store_credit: :available_store_credit_total, deprecator: Spree::Deprecation
|
75
|
-
|
76
68
|
def available_store_credit_total(currency:)
|
77
69
|
store_credits.to_a.
|
78
70
|
select { |credit| credit.currency == currency }.
|
@@ -85,5 +77,38 @@ module Spree
|
|
85
77
|
currency: currency,
|
86
78
|
)
|
87
79
|
end
|
80
|
+
|
81
|
+
# Restrict to delete users with existing orders
|
82
|
+
#
|
83
|
+
# Override this in your user model class to add another logic.
|
84
|
+
#
|
85
|
+
# Ie. to allow to delete users with incomplete orders add:
|
86
|
+
#
|
87
|
+
# orders.complete.none?
|
88
|
+
#
|
89
|
+
def can_be_deleted?
|
90
|
+
orders.none?
|
91
|
+
end
|
92
|
+
|
93
|
+
# Updates the roles in keeping with the given ability's permissions
|
94
|
+
#
|
95
|
+
# Roles that are not accessible to the given ability will be ignored. It
|
96
|
+
# also ensure not to remove non accessible roles when assigning new
|
97
|
+
# accessible ones.
|
98
|
+
#
|
99
|
+
# @param given_roles [Spree::Role]
|
100
|
+
# @param ability [Spree::Ability]
|
101
|
+
def update_spree_roles(given_roles, ability:)
|
102
|
+
accessible_roles = Spree::Role.accessible_by(ability)
|
103
|
+
non_accessible_roles = Spree::Role.all - accessible_roles
|
104
|
+
new_accessible_roles = given_roles - non_accessible_roles
|
105
|
+
self.spree_roles = spree_roles - accessible_roles + new_accessible_roles
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def check_for_deletion
|
111
|
+
raise ActiveRecord::DeleteRestrictionError unless can_be_deleted?
|
112
|
+
end
|
88
113
|
end
|
89
114
|
end
|
data/app/models/spree/ability.rb
CHANGED
@@ -14,13 +14,6 @@ module Spree
|
|
14
14
|
|
15
15
|
attr_reader :user
|
16
16
|
|
17
|
-
CUSTOM_ALIASES_MAP = {
|
18
|
-
delete: :destroy,
|
19
|
-
display: :read,
|
20
|
-
new_action: :create,
|
21
|
-
read: :show
|
22
|
-
}.freeze
|
23
|
-
|
24
17
|
# Allows us to go beyond the standard cancan initialize method which makes it difficult for engines to
|
25
18
|
# modify the default +Ability+ of an application. The +ability+ argument must be a class that includes
|
26
19
|
# the +CanCan::Ability+ module. The registered ability should behave properly as a stand-alone class
|
@@ -40,38 +33,8 @@ module Spree
|
|
40
33
|
register_extension_abilities
|
41
34
|
end
|
42
35
|
|
43
|
-
def can?(action, *args)
|
44
|
-
super(normalize_action(action), *args)
|
45
|
-
end
|
46
|
-
|
47
|
-
def model_adapter(model_class, action)
|
48
|
-
super(model_class, normalize_action(action))
|
49
|
-
end
|
50
|
-
|
51
36
|
private
|
52
37
|
|
53
|
-
def normalize_action(action)
|
54
|
-
return action unless Spree::Config.use_custom_cancancan_actions
|
55
|
-
|
56
|
-
normalized_action = CUSTOM_ALIASES_MAP.fetch(action, action)
|
57
|
-
|
58
|
-
if action == :read
|
59
|
-
Spree::Deprecation.warn <<~WARN, caller(3)
|
60
|
-
The behavior of CanCanCan `:read` action alias will be changing in Solidus 3.0.
|
61
|
-
The current alias is: `:show, :to => :read`,
|
62
|
-
the new alias will be compliant with CanCanCan's default: `index, :show, :to => :read`
|
63
|
-
WARN
|
64
|
-
elsif CUSTOM_ALIASES_MAP.key? action
|
65
|
-
Spree::Deprecation.warn <<~WARN, caller(3)
|
66
|
-
Calling CanCanCan alias action #{action.inspect} is deprecated.
|
67
|
-
In Solidus 3.0 non-standard CanCanCan action aliases will be replaced with default ones,
|
68
|
-
please replace with #{normalized_action.inspect}.
|
69
|
-
WARN
|
70
|
-
end
|
71
|
-
|
72
|
-
normalized_action
|
73
|
-
end
|
74
|
-
|
75
38
|
# Before, this was the only way to extend this ability. Permission sets have been added since.
|
76
39
|
# It is recommended to use them instead for extension purposes if possible.
|
77
40
|
def register_extension_abilities
|
@@ -2,29 +2,11 @@
|
|
2
2
|
|
3
3
|
module Spree
|
4
4
|
class Address
|
5
|
-
# Provides a value object to help
|
6
|
-
#
|
5
|
+
# Provides a value object to help splitting and joining
|
6
|
+
# name fields
|
7
7
|
class Name
|
8
8
|
attr_reader :first_name, :last_name, :value
|
9
9
|
|
10
|
-
# Creates an instance of Spree::Address::Name parsing input attributes.
|
11
|
-
# @param attributes [Hash] an hash possibly containing name-related
|
12
|
-
# attributes (name, firstname, lastname, first_name, last_name)
|
13
|
-
# @return [Spree::Address::Name] the object created
|
14
|
-
def self.from_attributes(attributes)
|
15
|
-
params = attributes.with_indifferent_access
|
16
|
-
|
17
|
-
if params[:name].present?
|
18
|
-
Spree::Address::Name.new(params[:name])
|
19
|
-
elsif params[:firstname].present?
|
20
|
-
Spree::Address::Name.new(params[:firstname], params[:lastname])
|
21
|
-
elsif params[:first_name].present?
|
22
|
-
Spree::Address::Name.new(params[:first_name], params[:last_name])
|
23
|
-
else
|
24
|
-
Spree::Address::Name.new
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
10
|
def initialize(*components)
|
29
11
|
@value = components.join(' ').strip
|
30
12
|
initialize_name_components(components)
|