spree_core 4.5.0 → 4.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/finders/spree/countries/find.rb +1 -1
- data/app/finders/spree/option_values/find_available.rb +1 -1
- data/app/finders/spree/product_properties/find_available.rb +1 -1
- data/app/finders/spree/products/find.rb +21 -13
- data/app/finders/spree/taxons/find.rb +7 -10
- data/app/helpers/spree/base_helper.rb +3 -7
- data/app/helpers/spree/products_helper.rb +3 -3
- data/app/models/concerns/spree/metadata.rb +7 -2
- data/app/models/concerns/spree/named_type.rb +1 -1
- data/app/models/concerns/spree/product_scopes.rb +27 -23
- data/app/models/concerns/spree/translatable_resource.rb +25 -0
- data/app/models/concerns/spree/translatable_resource_scopes.rb +24 -0
- data/app/models/concerns/spree/translatable_resource_slug.rb +15 -0
- data/app/models/concerns/spree/user_roles.rb +3 -3
- data/app/models/spree/address.rb +6 -4
- data/app/models/spree/asset.rb +1 -1
- data/app/models/spree/base.rb +6 -1
- data/app/models/spree/calculator/default_tax.rb +1 -1
- data/app/models/spree/cms/sections/image_gallery.rb +1 -7
- data/app/models/spree/cms/sections/side_by_side_images.rb +1 -7
- data/app/models/spree/cms_page.rb +2 -2
- data/app/models/spree/cms_section.rb +1 -1
- data/app/models/spree/country.rb +2 -2
- data/app/models/spree/credit_card.rb +1 -1
- data/app/models/spree/customer_return.rb +2 -2
- data/app/models/spree/data_feed/google.rb +15 -0
- data/app/models/spree/data_feed.rb +40 -0
- data/app/models/spree/digital_link.rb +5 -1
- data/app/models/spree/image.rb +2 -2
- data/app/models/spree/legacy_user.rb +3 -3
- data/app/models/spree/line_item.rb +1 -1
- data/app/models/spree/log_entry.rb +5 -1
- data/app/models/spree/menu.rb +1 -1
- data/app/models/spree/option_type.rb +6 -2
- data/app/models/spree/option_value.rb +5 -1
- data/app/models/spree/order/store_credit.rb +8 -0
- data/app/models/spree/order.rb +9 -9
- data/app/models/spree/order_contents.rb +31 -0
- data/app/models/spree/payment.rb +7 -15
- data/app/models/spree/payment_method.rb +1 -1
- data/app/models/spree/payment_source.rb +1 -1
- data/app/models/spree/preference.rb +5 -1
- data/app/models/spree/price.rb +1 -1
- data/app/models/spree/product.rb +64 -25
- data/app/models/spree/product_property.rb +13 -4
- data/app/models/spree/promotion.rb +2 -2
- data/app/models/spree/property.rb +8 -2
- data/app/models/spree/prototype.rb +1 -1
- data/app/models/spree/refund.rb +1 -1
- data/app/models/spree/reimbursement.rb +1 -1
- data/app/models/spree/return_authorization.rb +1 -1
- data/app/models/spree/return_item.rb +5 -1
- data/app/models/spree/role.rb +1 -1
- data/app/models/spree/shipment.rb +5 -5
- data/app/models/spree/shipping_category.rb +1 -1
- data/app/models/spree/shipping_method.rb +1 -1
- data/app/models/spree/stock/estimator.rb +1 -1
- data/app/models/spree/stock/splitter/weight.rb +1 -1
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_location.rb +1 -1
- data/app/models/spree/stock_transfer.rb +3 -3
- data/app/models/spree/store.rb +22 -3
- data/app/models/spree/store_credit.rb +2 -2
- data/app/models/spree/taxon.rb +47 -7
- data/app/models/spree/taxon_image.rb +2 -2
- data/app/models/spree/taxonomy.rb +5 -1
- data/app/models/spree/variant.rb +6 -9
- data/app/models/spree/wishlist.rb +6 -2
- data/app/models/spree/zone.rb +2 -2
- data/app/services/spree/data_feeds/google/optional_attributes.rb +23 -0
- data/app/services/spree/data_feeds/google/optional_sub_attributes.rb +21 -0
- data/app/services/spree/data_feeds/google/products_list.rb +14 -0
- data/app/services/spree/data_feeds/google/required_attributes.rb +67 -0
- data/app/services/spree/data_feeds/google/rss.rb +107 -0
- data/app/services/spree/locales/set_fallback_locale_for_store.rb +16 -0
- data/app/services/spree/seeds/countries.rb +12 -27
- data/app/services/spree/seeds/states.rb +8 -17
- data/app/services/spree/stock_locations/stock_items/create.rb +12 -18
- data/app/sorters/spree/products/sort.rb +23 -0
- data/app/validators/db_maximum_length_validator.rb +2 -6
- data/brakeman.ignore +326 -18
- data/config/initializers/friendly_id.rb +2 -0
- data/config/initializers/mobility.rb +16 -0
- data/config/initializers/rails61_fixes.rb +1 -3
- data/config/locales/en.yml +7 -0
- data/db/migrate/20220706112554_create_product_name_and_description_translations_for_mobility_table_backend.rb +27 -0
- data/db/migrate/20220715083542_create_spree_product_translations_for_mobility.rb +7 -0
- data/db/migrate/20220715120222_change_product_name_null_to_true.rb +5 -0
- data/db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb +27 -0
- data/db/migrate/20220718100948_change_taxon_name_null_to_true.rb +5 -0
- data/db/migrate/20220802070609_add_locale_to_friendly_id_slugs.rb +11 -0
- data/db/migrate/20220802073225_create_spree_product_slug_translations_for_mobility_table_backend.rb +5 -0
- data/db/migrate/20220804073928_transfer_data_to_translatable_tables.rb +66 -0
- data/db/migrate/20221215151408_add_selected_locale_to_spree_users.rb +8 -0
- data/db/migrate/20221219123957_add_deleted_at_to_product_translations.rb +6 -0
- data/db/migrate/20221220133432_add_uniqueness_constraint_to_product_translations.rb +5 -0
- data/db/migrate/20221229132350_create_spree_data_feed_settings.rb +14 -0
- data/db/migrate/20230103144439_create_option_type_translations.rb +26 -0
- data/db/migrate/20230103151034_create_option_value_translations.rb +26 -0
- data/db/migrate/20230109084253_create_product_property_translations.rb +25 -0
- data/db/migrate/20230109094907_transfer_options_data_to_translatable_tables.rb +58 -0
- data/db/migrate/20230109105943_create_property_translations.rb +26 -0
- data/db/migrate/20230109110840_transfer_property_data_to_translatable_tables.rb +59 -0
- data/db/migrate/20230110142344_backfill_friendly_id_slug_locale.rb +15 -0
- data/db/migrate/20230111121534_add_additional_taxon_translation_fields.rb +8 -0
- data/db/migrate/20230111122511_transfer_product_and_taxon_data_to_translatable_tables.rb +82 -0
- data/db/migrate/20230117115531_create_taxonomy_translations.rb +24 -0
- data/db/migrate/20230117120430_allow_null_taxonomy_name.rb +5 -0
- data/db/migrate/20230117121303_transfer_taxonomy_data_to_translatable_tables.rb +11 -0
- data/db/migrate/20230210142732_create_store_translations.rb +50 -0
- data/db/migrate/20230210142849_transfer_store_data_to_translatable_tables.rb +11 -0
- data/db/migrate/20230210230434_add_deleted_at_to_store_translations.rb +6 -0
- data/db/migrate/20230415155958_rename_data_feed_settings_table.rb +5 -0
- data/db/migrate/20230415160828_rename_data_feed_table_columns.rb +7 -0
- data/db/migrate/20230415161226_add_indexes_to_data_feeds_table.rb +5 -0
- data/db/migrate/20230512094803_rename_data_feeds_column_provider_to_type.rb +5 -0
- data/db/migrate/20230514162157_add_index_on_locale_and_permalink_to_spree_taxons.rb +5 -0
- data/lib/mobility/plugins/store_based_fallbacks.rb +55 -0
- data/lib/spree/core/configuration.rb +2 -1
- data/lib/spree/core/controller_helpers/auth.rb +1 -1
- data/lib/spree/core/controller_helpers/common.rb +5 -5
- data/lib/spree/core/controller_helpers/locale.rb +33 -2
- data/lib/spree/core/dependencies.rb +70 -94
- data/lib/spree/core/dependencies_helper.rb +19 -0
- data/lib/spree/core/engine.rb +7 -1
- data/lib/spree/core/preferences/preferable_class_methods.rb +1 -1
- data/lib/spree/core/product_duplicator.rb +4 -1
- data/lib/spree/core/product_filters.rb +7 -4
- data/lib/spree/core/search/base.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +2 -0
- data/lib/spree/permitted_attributes.rb +1 -1
- data/lib/spree/testing_support/controller_requests.rb +10 -10
- data/lib/spree/testing_support/factories/google_data_feed_factory.rb +8 -0
- data/lib/spree/testing_support/factories/product_factory.rb +6 -0
- data/lib/spree/testing_support/factories/product_translation_factory.rb +6 -0
- data/lib/spree/testing_support/factories/store_factory.rb +3 -0
- data/lib/spree/testing_support/factories/variant_factory.rb +4 -0
- data/lib/spree/translation_migrations.rb +40 -0
- data/lib/spree_core.rb +1 -0
- data/spree_core.gemspec +6 -3
- metadata +147 -14
@@ -6,6 +6,7 @@ module Spree
|
|
6
6
|
|
7
7
|
included do
|
8
8
|
before_action :set_locale
|
9
|
+
before_action :set_fallback_locale
|
9
10
|
|
10
11
|
if defined?(helper_method)
|
11
12
|
helper_method :supported_locales
|
@@ -21,16 +22,36 @@ module Spree
|
|
21
22
|
I18n.locale = current_locale
|
22
23
|
end
|
23
24
|
|
25
|
+
def set_fallback_locale
|
26
|
+
return unless respond_to?(:current_store) && current_store.present?
|
27
|
+
|
28
|
+
Spree::Locales::SetFallbackLocaleForStore.new.call(store: current_store)
|
29
|
+
end
|
30
|
+
|
24
31
|
def current_locale
|
25
|
-
@current_locale ||= if
|
32
|
+
@current_locale ||= if user_locale?
|
33
|
+
try_spree_current_user.selected_locale
|
34
|
+
elsif params_locale?
|
26
35
|
params[:locale]
|
27
|
-
elsif
|
36
|
+
elsif config_locale?
|
28
37
|
config_locale
|
29
38
|
else
|
30
39
|
current_store&.default_locale || Rails.application.config.i18n.default_locale || I18n.default_locale
|
31
40
|
end
|
32
41
|
end
|
33
42
|
|
43
|
+
def config_locale?
|
44
|
+
respond_to?(:config_locale, true) && config_locale.present?
|
45
|
+
end
|
46
|
+
|
47
|
+
def params_locale?
|
48
|
+
params[:locale].present? && supported_locale?(params[:locale])
|
49
|
+
end
|
50
|
+
|
51
|
+
def user_locale?
|
52
|
+
Spree::Config.use_user_locale && try_spree_current_user && supported_locale?(try_spree_current_user.selected_locale)
|
53
|
+
end
|
54
|
+
|
34
55
|
def supported_locales
|
35
56
|
@supported_locales ||= current_store&.supported_locales_list
|
36
57
|
end
|
@@ -54,6 +75,16 @@ module Spree
|
|
54
75
|
|
55
76
|
I18n.locale.to_s
|
56
77
|
end
|
78
|
+
|
79
|
+
def find_with_fallback_default_locale(&block)
|
80
|
+
result = begin
|
81
|
+
block.call
|
82
|
+
rescue ActiveRecord::RecordNotFound => _e
|
83
|
+
nil
|
84
|
+
end
|
85
|
+
|
86
|
+
result || Mobility.with_locale(current_store.default_locale) { block.call }
|
87
|
+
end
|
57
88
|
end
|
58
89
|
end
|
59
90
|
end
|
@@ -3,128 +3,104 @@ require_relative 'dependencies_helper'
|
|
3
3
|
module Spree
|
4
4
|
module Core
|
5
5
|
class Dependencies
|
6
|
-
|
6
|
+
INJECTION_POINTS_WITH_DEFAULTS = {
|
7
|
+
# ability
|
8
|
+
ability_class: 'Spree::Ability',
|
7
9
|
|
8
|
-
INJECTION_POINTS = [
|
9
|
-
:ability_class,
|
10
|
-
:cart_create_service, :cart_add_item_service, :cart_remove_item_service,
|
11
|
-
:cart_remove_line_item_service, :cart_set_item_quantity_service, :cart_recalculate_service,
|
12
|
-
:cms_page_finder, :cart_update_service, :checkout_next_service, :checkout_advance_service, :checkout_update_service,
|
13
|
-
:checkout_complete_service, :checkout_add_store_credit_service, :checkout_remove_store_credit_service, :checkout_get_shipping_rates_service,
|
14
|
-
:coupon_handler, :menu_finder, :country_finder, :current_order_finder, :credit_card_finder,
|
15
|
-
:completed_order_finder, :order_sorter, :cart_compare_line_items_service, :collection_paginator, :products_sorter,
|
16
|
-
:products_finder, :taxon_finder, :line_item_by_variant_finder, :cart_estimate_shipping_rates_service,
|
17
|
-
:account_create_address_service, :account_update_address_service, :account_create_service, :account_update_service,
|
18
|
-
:address_finder, :collection_sorter, :error_handler, :current_store_finder, :cart_empty_service, :cart_destroy_service,
|
19
|
-
:classification_reposition_service, :credit_cards_destroy_service, :cart_associate_service, :cart_change_currency_service,
|
20
|
-
:line_item_create_service, :line_item_update_service, :line_item_destroy_service,
|
21
|
-
:order_approve_service, :order_cancel_service, :shipment_change_state_service, :shipment_update_service,
|
22
|
-
:shipment_create_service, :shipment_add_item_service, :shipment_remove_item_service,
|
23
|
-
:payment_create_service, :address_create_service, :address_update_service,
|
24
|
-
:checkout_select_shipping_method_service
|
25
|
-
].freeze
|
26
|
-
|
27
|
-
attr_accessor *INJECTION_POINTS
|
28
|
-
|
29
|
-
def initialize
|
30
|
-
set_default_ability
|
31
|
-
set_default_services
|
32
|
-
set_default_finders
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def set_default_ability
|
38
|
-
@ability_class = 'Spree::Ability'
|
39
|
-
end
|
40
|
-
|
41
|
-
def set_default_services
|
42
10
|
# cart
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
11
|
+
cart_compare_line_items_service: 'Spree::CompareLineItems',
|
12
|
+
cart_create_service: 'Spree::Cart::Create',
|
13
|
+
cart_add_item_service: 'Spree::Cart::AddItem',
|
14
|
+
cart_update_service: 'Spree::Cart::Update',
|
15
|
+
cart_recalculate_service: 'Spree::Cart::Recalculate',
|
16
|
+
cart_remove_item_service: 'Spree::Cart::RemoveItem',
|
17
|
+
cart_remove_line_item_service: 'Spree::Cart::RemoveLineItem',
|
18
|
+
cart_set_item_quantity_service: 'Spree::Cart::SetQuantity',
|
19
|
+
cart_estimate_shipping_rates_service: 'Spree::Cart::EstimateShippingRates',
|
20
|
+
cart_empty_service: 'Spree::Cart::Empty',
|
21
|
+
cart_destroy_service: 'Spree::Cart::Destroy',
|
22
|
+
cart_associate_service: 'Spree::Cart::Associate',
|
23
|
+
cart_change_currency_service: 'Spree::Cart::ChangeCurrency',
|
56
24
|
|
57
25
|
# checkout
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
26
|
+
checkout_next_service: 'Spree::Checkout::Next',
|
27
|
+
checkout_advance_service: 'Spree::Checkout::Advance',
|
28
|
+
checkout_update_service: 'Spree::Checkout::Update',
|
29
|
+
checkout_complete_service: 'Spree::Checkout::Complete',
|
30
|
+
checkout_add_store_credit_service: 'Spree::Checkout::AddStoreCredit',
|
31
|
+
checkout_remove_store_credit_service: 'Spree::Checkout::RemoveStoreCredit',
|
32
|
+
checkout_get_shipping_rates_service: 'Spree::Checkout::GetShippingRates',
|
33
|
+
checkout_select_shipping_method_service: 'Spree::Checkout::SelectShippingMethod',
|
66
34
|
|
67
35
|
# order
|
68
|
-
|
69
|
-
|
36
|
+
order_approve_service: 'Spree::Orders::Approve',
|
37
|
+
order_cancel_service: 'Spree::Orders::Cancel',
|
70
38
|
|
71
39
|
# shipment
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
40
|
+
shipment_change_state_service: 'Spree::Shipments::ChangeState',
|
41
|
+
shipment_create_service: 'Spree::Shipments::Create',
|
42
|
+
shipment_update_service: 'Spree::Shipments::Update',
|
43
|
+
shipment_add_item_service: 'Spree::Shipments::AddItem',
|
44
|
+
shipment_remove_item_service: 'Spree::Shipments::RemoveItem',
|
77
45
|
|
78
46
|
# sorter
|
79
|
-
|
80
|
-
|
81
|
-
|
47
|
+
collection_sorter: 'Spree::BaseSorter',
|
48
|
+
order_sorter: 'Spree::BaseSorter',
|
49
|
+
products_sorter: 'Spree::Products::Sort',
|
82
50
|
|
83
51
|
# paginator
|
84
|
-
|
52
|
+
collection_paginator: 'Spree::Shared::Paginate',
|
85
53
|
|
86
54
|
# coupons
|
87
55
|
# TODO: we should split this service into 2 separate - Add and Remove
|
88
|
-
|
56
|
+
coupon_handler: 'Spree::PromotionHandler::Coupon',
|
89
57
|
|
90
58
|
# account
|
91
|
-
|
92
|
-
|
59
|
+
account_create_service: 'Spree::Account::Create',
|
60
|
+
account_update_service: 'Spree::Account::Update',
|
93
61
|
|
94
62
|
# addresses
|
95
|
-
|
96
|
-
|
63
|
+
address_create_service: 'Spree::Addresses::Create',
|
64
|
+
address_update_service: 'Spree::Addresses::Update',
|
97
65
|
|
98
66
|
# credit cards
|
99
|
-
|
67
|
+
credit_cards_destroy_service: 'Spree::CreditCards::Destroy',
|
100
68
|
|
101
69
|
# classifications
|
102
|
-
|
70
|
+
classification_reposition_service: 'Spree::Classifications::Reposition',
|
103
71
|
|
104
72
|
# line items
|
105
|
-
|
106
|
-
|
107
|
-
|
73
|
+
line_item_create_service: 'Spree::LineItems::Create',
|
74
|
+
line_item_update_service: 'Spree::LineItems::Update',
|
75
|
+
line_item_destroy_service: 'Spree::LineItems::Destroy',
|
108
76
|
|
109
|
-
|
77
|
+
payment_create_service: 'Spree::Payments::Create',
|
110
78
|
|
111
79
|
# errors
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
80
|
+
error_handler: 'Spree::ErrorReporter',
|
81
|
+
|
82
|
+
# data feeds
|
83
|
+
data_feeds_google_rss_service: 'Spree::DataFeeds::Google::Rss',
|
84
|
+
data_feeds_google_optional_attributes_service: 'Spree::DataFeeds::Google::OptionalAttributes',
|
85
|
+
data_feeds_google_required_attributes_service: 'Spree::DataFeeds::Google::RequiredAttributes',
|
86
|
+
data_feeds_google_optional_sub_attributes_service: 'Spree::DataFeeds::Google::OptionalSubAttributes',
|
87
|
+
data_feeds_google_products_list: 'Spree::DataFeeds::Google::ProductsList',
|
88
|
+
|
89
|
+
# finders
|
90
|
+
address_finder: 'Spree::Addresses::Find',
|
91
|
+
country_finder: 'Spree::Countries::Find',
|
92
|
+
cms_page_finder: 'Spree::CmsPages::Find',
|
93
|
+
menu_finder: 'Spree::Menus::Find',
|
94
|
+
current_order_finder: 'Spree::Orders::FindCurrent',
|
95
|
+
current_store_finder: 'Spree::Stores::FindCurrent',
|
96
|
+
completed_order_finder: 'Spree::Orders::FindComplete',
|
97
|
+
credit_card_finder: 'Spree::CreditCards::Find',
|
98
|
+
products_finder: 'Spree::Products::Find',
|
99
|
+
taxon_finder: 'Spree::Taxons::Find',
|
100
|
+
line_item_by_variant_finder: 'Spree::LineItems::FindByVariant'
|
101
|
+
}.freeze
|
102
|
+
|
103
|
+
include Spree::DependenciesHelper
|
128
104
|
end
|
129
105
|
end
|
130
106
|
end
|
@@ -1,5 +1,15 @@
|
|
1
1
|
module Spree
|
2
2
|
module DependenciesHelper
|
3
|
+
def self.included(base)
|
4
|
+
injection_points = base::INJECTION_POINTS_WITH_DEFAULTS.keys.freeze
|
5
|
+
base.const_set(:INJECTION_POINTS, injection_points)
|
6
|
+
base.attr_accessor(*injection_points)
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
set_default_values
|
11
|
+
end
|
12
|
+
|
3
13
|
def current_values
|
4
14
|
values = []
|
5
15
|
self.class::INJECTION_POINTS.each do |injection_point|
|
@@ -7,5 +17,14 @@ module Spree
|
|
7
17
|
end
|
8
18
|
values
|
9
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def set_default_values
|
24
|
+
self.class::INJECTION_POINTS_WITH_DEFAULTS.each do |injection_point, default_value|
|
25
|
+
value = default_value.respond_to?(:call) ? default_value.call : default_value
|
26
|
+
instance_variable_set("@#{injection_point}", value)
|
27
|
+
end
|
28
|
+
end
|
10
29
|
end
|
11
30
|
end
|
data/lib/spree/core/engine.rb
CHANGED
@@ -11,7 +11,8 @@ module Spree
|
|
11
11
|
:adjusters,
|
12
12
|
:stock_splitters,
|
13
13
|
:promotions,
|
14
|
-
:line_item_comparison_hooks
|
14
|
+
:line_item_comparison_hooks,
|
15
|
+
:data_feed_types)
|
15
16
|
SpreeCalculators = Struct.new(:shipping_methods, :tax_rates, :promotion_actions_create_adjustments, :promotion_actions_create_item_adjustments)
|
16
17
|
PromoEnvironment = Struct.new(:rules, :actions)
|
17
18
|
isolate_namespace Spree
|
@@ -26,6 +27,7 @@ module Spree
|
|
26
27
|
app.config.active_record.yaml_column_permitted_classes = [Symbol, BigDecimal]
|
27
28
|
Spree::Config = app.config.spree.preferences
|
28
29
|
Spree::Dependencies = app.config.spree.dependencies
|
30
|
+
Spree::Deprecation = ActiveSupport::Deprecation.new
|
29
31
|
end
|
30
32
|
|
31
33
|
initializer 'spree.register.calculators', before: :after_initialize do |app|
|
@@ -122,6 +124,10 @@ module Spree
|
|
122
124
|
Promotion::Actions::CreateLineItems,
|
123
125
|
Promotion::Actions::FreeShipping
|
124
126
|
]
|
127
|
+
|
128
|
+
Rails.application.config.spree.data_feed_types = [
|
129
|
+
Spree::DataFeed::Google
|
130
|
+
]
|
125
131
|
end
|
126
132
|
|
127
133
|
initializer 'spree.promo.register.promotions.actions' do |app|
|
@@ -19,7 +19,7 @@ module Spree::Preferences
|
|
19
19
|
value = convert_preference_value(value, type)
|
20
20
|
preferences[name] = value
|
21
21
|
|
22
|
-
|
22
|
+
Spree::Deprecation.warn("`#{name}` is deprecated. #{deprecated}") if deprecated
|
23
23
|
|
24
24
|
# If this is an activerecord object, we need to inform
|
25
25
|
# ActiveRecord::Dirty that this value has changed, since this is an
|
@@ -26,7 +26,10 @@ module Spree
|
|
26
26
|
|
27
27
|
def duplicate_product
|
28
28
|
product.dup.tap do |new_product|
|
29
|
-
new_product.
|
29
|
+
new_product.translations.each do |t|
|
30
|
+
t.name = "COPY OF #{t.name}"
|
31
|
+
t.slug = nil
|
32
|
+
end
|
30
33
|
new_product.taxons = product.taxons
|
31
34
|
new_product.stores = product.stores
|
32
35
|
new_product.created_at = nil
|
@@ -98,18 +98,21 @@ module Spree
|
|
98
98
|
conds.each do |new_scope|
|
99
99
|
scope = scope.or(new_scope)
|
100
100
|
end
|
101
|
-
|
101
|
+
Product.with_property('brand').join_translation_table(ProductProperty).where(scope)
|
102
102
|
end
|
103
103
|
|
104
104
|
def self.brand_filter
|
105
105
|
brand_property = Spree::Property.find_by(name: 'brand')
|
106
106
|
brands = brand_property ? Spree::ProductProperty.where(property_id: brand_property.id).pluck(:value).uniq.map(&:to_s) : []
|
107
|
-
|
108
|
-
|
107
|
+
|
108
|
+
conditions = brands.map do |brand|
|
109
|
+
[brand, { ProductProperty.translation_table_alias => { value: brand } }]
|
110
|
+
end.to_h
|
111
|
+
|
109
112
|
{
|
110
113
|
name: I18n.t('spree.taxonomy_brands_name'),
|
111
114
|
scope: :brand_any,
|
112
|
-
conds:
|
115
|
+
conds: conditions,
|
113
116
|
labels: brands.sort.map { |k| [k, k] }
|
114
117
|
}
|
115
118
|
end
|
@@ -83,7 +83,7 @@ module Spree
|
|
83
83
|
# method should return new scope based on base_scope
|
84
84
|
def get_products_conditions_for(base_scope, query)
|
85
85
|
unless query.blank?
|
86
|
-
base_scope = base_scope.
|
86
|
+
base_scope = base_scope.i18n { name.matches("%#{query}%").or(description.matches("%#{query}%")) }
|
87
87
|
end
|
88
88
|
base_scope
|
89
89
|
end
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
@@ -13,6 +13,7 @@ require 'cancan'
|
|
13
13
|
require 'friendly_id'
|
14
14
|
require 'kaminari'
|
15
15
|
require 'monetize'
|
16
|
+
require 'mobility'
|
16
17
|
require 'paranoia'
|
17
18
|
require 'ransack'
|
18
19
|
require 'state_machines-activerecord'
|
@@ -116,6 +117,7 @@ require 'spree/core/version'
|
|
116
117
|
|
117
118
|
require 'spree/core/number_generator'
|
118
119
|
require 'spree/migrations'
|
120
|
+
require 'spree/translation_migrations'
|
119
121
|
require 'spree/core/engine'
|
120
122
|
|
121
123
|
require 'spree/i18n'
|
@@ -147,7 +147,7 @@ module Spree
|
|
147
147
|
|
148
148
|
# TODO: Should probably use something like Spree.user_class.attributes
|
149
149
|
@@user_attributes = [:email, :bill_address_id, :ship_address_id, :password, :first_name, :last_name,
|
150
|
-
:password_confirmation, { public_metadata: {}, private_metadata: {} }]
|
150
|
+
:password_confirmation, { public_metadata: {}, private_metadata: {} }, :selected_locale]
|
151
151
|
|
152
152
|
@@variant_attributes = [
|
153
153
|
:name, :presentation, :cost_price, :discontinue_on, :lock_version,
|
@@ -8,7 +8,7 @@ module Spree
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def spree_get(action, parameters = nil, session = nil, flash = nil)
|
11
|
-
|
11
|
+
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
12
12
|
ControllerRequests#spree_get is deprecated and will be removed in Spree 5.0.
|
13
13
|
Please use get, params: {}
|
14
14
|
DEPRECATION
|
@@ -17,7 +17,7 @@ module Spree
|
|
17
17
|
|
18
18
|
# Executes a request simulating POST HTTP method and set/volley the response
|
19
19
|
def spree_post(action, parameters = nil, session = nil, flash = nil)
|
20
|
-
|
20
|
+
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
21
21
|
ControllerRequests#spree_post is deprecated and will be removed in Spree 5.0.
|
22
22
|
Please use post, params: {}
|
23
23
|
DEPRECATION
|
@@ -26,7 +26,7 @@ module Spree
|
|
26
26
|
|
27
27
|
# Executes a request simulating PUT HTTP method and set/volley the response
|
28
28
|
def spree_put(action, parameters = nil, session = nil, flash = nil)
|
29
|
-
|
29
|
+
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
30
30
|
ControllerRequests#spree_put is deprecated and will be removed in Spree 5.0.
|
31
31
|
Please use put, params: {}
|
32
32
|
DEPRECATION
|
@@ -35,7 +35,7 @@ module Spree
|
|
35
35
|
|
36
36
|
# # Executes a request simulating PATCH HTTP method and set/volley the response
|
37
37
|
def spree_patch(action, parameters = nil, session = nil, flash = nil)
|
38
|
-
|
38
|
+
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
39
39
|
ControllerRequests#spree_patch is deprecated and will be removed in Spree 5.0.
|
40
40
|
Please use patch, params: {}
|
41
41
|
DEPRECATION
|
@@ -44,7 +44,7 @@ module Spree
|
|
44
44
|
|
45
45
|
# Executes a request simulating DELETE HTTP method and set/volley the response
|
46
46
|
def spree_delete(action, parameters = nil, session = nil, flash = nil)
|
47
|
-
|
47
|
+
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
48
48
|
ControllerRequests#spree_delete is deprecated and will be removed in Spree 5.0.
|
49
49
|
Please use delete, params: {}
|
50
50
|
DEPRECATION
|
@@ -52,35 +52,35 @@ module Spree
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def spree_xhr_get(action, parameters = nil, session = nil, flash = nil)
|
55
|
-
|
55
|
+
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
56
56
|
ControllerRequests#spree_xhr_get is deprecated and will be removed in Spree 5.0.
|
57
57
|
DEPRECATION
|
58
58
|
process_spree_xhr_action(action, parameters, session, flash, :get)
|
59
59
|
end
|
60
60
|
|
61
61
|
def spree_xhr_post(action, parameters = nil, session = nil, flash = nil)
|
62
|
-
|
62
|
+
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
63
63
|
ControllerRequests#spree_xhr_post is deprecated and will be removed in Spree 5.0.
|
64
64
|
DEPRECATION
|
65
65
|
process_spree_xhr_action(action, parameters, session, flash, :post)
|
66
66
|
end
|
67
67
|
|
68
68
|
def spree_xhr_put(action, parameters = nil, session = nil, flash = nil)
|
69
|
-
|
69
|
+
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
70
70
|
ControllerRequests#spree_xhr_put is deprecated and will be removed in Spree 5.0.
|
71
71
|
DEPRECATION
|
72
72
|
process_spree_xhr_action(action, parameters, session, flash, :put)
|
73
73
|
end
|
74
74
|
|
75
75
|
def spree_xhr_patch(action, parameters = nil, session = nil, flash = nil)
|
76
|
-
|
76
|
+
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
77
77
|
ControllerRequests#spree_xhr_patch is deprecated and will be removed in Spree 5.0.
|
78
78
|
DEPRECATION
|
79
79
|
process_spree_xhr_action(action, parameters, session, flash, :patch)
|
80
80
|
end
|
81
81
|
|
82
82
|
def spree_xhr_delete(action, parameters = nil, session = nil, flash = nil)
|
83
|
-
|
83
|
+
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
84
84
|
ControllerRequests#spree_xhr_delete is deprecated and will be removed in Spree 5.0.
|
85
85
|
DEPRECATION
|
86
86
|
process_spree_xhr_action(action, parameters, session, flash, :delete)
|
@@ -52,6 +52,12 @@ FactoryBot.define do
|
|
52
52
|
factory :product_with_option_types do
|
53
53
|
after(:create) { |product| create(:product_option_type, product: product) }
|
54
54
|
end
|
55
|
+
factory :product_with_properties do
|
56
|
+
after(:create) do |product|
|
57
|
+
create(:property, :brand, id: 10)
|
58
|
+
create(:product_property, product: product, property_id: 10, value: 'Epsilon')
|
59
|
+
end
|
60
|
+
end
|
55
61
|
end
|
56
62
|
end
|
57
63
|
end
|
@@ -12,6 +12,9 @@ FactoryBot.define do
|
|
12
12
|
facebook { 'spreecommerce' }
|
13
13
|
twitter { 'spreecommerce' }
|
14
14
|
instagram { 'spreecommerce' }
|
15
|
+
meta_description { 'Sample store description.' }
|
16
|
+
digital_asset_authorized_clicks { 5 }
|
17
|
+
digital_asset_authorized_days { 7 }
|
15
18
|
|
16
19
|
trait :with_favicon do
|
17
20
|
transient do
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Spree
|
2
|
+
class TranslationMigrations
|
3
|
+
def initialize(resource_class, default_locale)
|
4
|
+
@resource_class = resource_class
|
5
|
+
@translations_table = resource_class::Translation.table_name
|
6
|
+
@translatable_fields = resource_class.translatable_fields.join(', ')
|
7
|
+
@foreign_key = "#{resource_class.table_name.singularize}_id"
|
8
|
+
@default_locale = default_locale
|
9
|
+
end
|
10
|
+
|
11
|
+
def transfer_translation_data
|
12
|
+
nullify_translatable_fields = @resource_class.translatable_fields.map { |f| "#{f}=null" }.join(', ')
|
13
|
+
|
14
|
+
unless @resource_class::Translation.exists?
|
15
|
+
ActiveRecord::Base.connection.execute("
|
16
|
+
INSERT INTO #{@translations_table} (#{@translatable_fields}, #{@foreign_key}, locale, created_at, updated_at)
|
17
|
+
SELECT #{@translatable_fields}, id, '#{@default_locale}' as locale, created_at, updated_at FROM #{@resource_class.table_name};
|
18
|
+
")
|
19
|
+
ActiveRecord::Base.connection.execute("
|
20
|
+
UPDATE #{@resource_class.table_name}
|
21
|
+
SET #{nullify_translatable_fields};
|
22
|
+
")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def revert_translation_data_transfer
|
27
|
+
translation_table_fields = @resource_class.translatable_fields.map { |f| "#{@translations_table}.#{f}" }.join(', ')
|
28
|
+
row_expression = @resource_class.translatable_fields.count == 1 ? 'ROW' : ''
|
29
|
+
|
30
|
+
ActiveRecord::Base.connection.execute("
|
31
|
+
UPDATE #{@resource_class.table_name}
|
32
|
+
SET (#{@translatable_fields}) = #{row_expression}(#{translation_table_fields})
|
33
|
+
FROM #{@translations_table}
|
34
|
+
WHERE #{@translations_table}.#{@foreign_key} = #{@resource_class.table_name}.id
|
35
|
+
")
|
36
|
+
|
37
|
+
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{@translations_table}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/spree_core.rb
CHANGED
data/spree_core.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
"source_code_uri" => "https://github.com/spree/spree/tree/v#{s.version}",
|
21
21
|
}
|
22
22
|
|
23
|
-
s.required_ruby_version = '>=
|
23
|
+
s.required_ruby_version = '>= 3.0'
|
24
24
|
s.required_rubygems_version = '>= 1.8.23'
|
25
25
|
|
26
26
|
s.files = `git ls-files`.split("\n").reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
actionpack actionview activejob activemodel activerecord
|
31
31
|
activestorage activesupport railties
|
32
32
|
].each do |rails_gem|
|
33
|
-
s.add_dependency rails_gem, '>= 6.1'
|
33
|
+
s.add_dependency rails_gem, '>= 6.1', '< 7.2'
|
34
34
|
end
|
35
35
|
|
36
36
|
s.add_dependency 'activemerchant', '~> 1.67'
|
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
s.add_dependency 'money', '~> 6.13'
|
46
46
|
s.add_dependency 'monetize', '~> 1.9'
|
47
47
|
s.add_dependency 'paranoia', '~> 2.4'
|
48
|
-
s.add_dependency 'ransack', '>=
|
48
|
+
s.add_dependency 'ransack', '>= 4.1'
|
49
49
|
s.add_dependency 'rexml'
|
50
50
|
s.add_dependency 'state_machines-activerecord', '~> 0.6'
|
51
51
|
s.add_dependency 'state_machines-activemodel', '~> 0.7'
|
@@ -54,4 +54,7 @@ Gem::Specification.new do |s|
|
|
54
54
|
s.add_dependency 'image_processing', '~> 1.2'
|
55
55
|
s.add_dependency 'active_storage_validations', '~> 0.9', '<= 0.9.5'
|
56
56
|
s.add_dependency 'activerecord-typedstore'
|
57
|
+
s.add_dependency 'mobility', '~> 1.2.9'
|
58
|
+
s.add_dependency 'mobility-ransack', '~> 1.2.1'
|
59
|
+
s.add_dependency 'friendly_id-mobility', '~> 1.0.4'
|
57
60
|
end
|