spree_core 4.7.3 → 4.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/app/finders/spree/taxons/find.rb +7 -3
- data/app/models/concerns/spree/product_scopes.rb +19 -19
- data/app/models/concerns/spree/user_address.rb +4 -2
- data/app/models/spree/address.rb +1 -20
- data/app/models/spree/asset.rb +1 -1
- data/app/models/spree/cms_page.rb +1 -1
- data/app/models/spree/country.rb +0 -26
- data/app/models/spree/credit_card.rb +4 -2
- data/app/models/spree/customer_return.rb +1 -1
- data/app/models/spree/digital.rb +1 -1
- data/app/models/spree/digital_link.rb +1 -1
- data/app/models/spree/inventory_unit.rb +1 -1
- data/app/models/spree/line_item.rb +1 -1
- data/app/models/spree/menu.rb +1 -1
- data/app/models/spree/menu_item.rb +1 -1
- data/app/models/spree/option_type.rb +3 -3
- data/app/models/spree/option_value.rb +3 -3
- data/app/models/spree/order.rb +5 -3
- data/app/models/spree/payment.rb +1 -1
- data/app/models/spree/payment_capture_event.rb +1 -1
- data/app/models/spree/price.rb +3 -1
- data/app/models/spree/product.rb +24 -13
- data/app/models/spree/product_property.rb +4 -2
- data/app/models/spree/promotion.rb +1 -1
- data/app/models/spree/property.rb +6 -4
- 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 +1 -1
- data/app/models/spree/shipment.rb +1 -1
- data/app/models/spree/shipping_category.rb +1 -1
- data/app/models/spree/shipping_method.rb +1 -1
- data/app/models/spree/stock_item.rb +2 -2
- data/app/models/spree/stock_location.rb +6 -1
- data/app/models/spree/stock_movement.rb +1 -1
- data/app/models/spree/stock_transfer.rb +1 -1
- data/app/models/spree/store.rb +2 -4
- data/app/models/spree/store_credit.rb +1 -1
- data/app/models/spree/store_favicon_image.rb +11 -2
- data/app/models/spree/tax_category.rb +1 -1
- data/app/models/spree/tax_rate.rb +1 -1
- data/app/models/spree/taxon.rb +20 -4
- data/app/models/spree/taxonomy.rb +3 -3
- data/app/models/spree/variant.rb +9 -4
- data/app/models/spree/wished_item.rb +1 -1
- data/app/models/spree/wishlist.rb +1 -1
- data/app/models/spree/zone.rb +1 -1
- data/app/services/spree/addresses/update.rb +1 -0
- data/app/services/spree/seeds/all.rb +15 -13
- data/app/services/spree/seeds/stores.rb +2 -2
- data/app/sorters/spree/products/sort.rb +1 -1
- data/config/initializers/mobility.rb +1 -0
- data/config/locales/en.yml +2 -36
- data/config/routes.rb +7 -8
- data/db/migrate/20210929090344_create_stock_item_stock_location_id_variant_id_coalesce_deleted_at_unique_index.rb +1 -28
- data/db/migrate/20230103144439_create_option_type_translations.rb +0 -1
- data/db/migrate/20230103151034_create_option_value_translations.rb +0 -1
- data/db/migrate/20230109084253_create_product_property_translations.rb +0 -1
- data/db/migrate/20230109105943_create_property_translations.rb +0 -2
- data/db/migrate/20230110142344_backfill_friendly_id_slug_locale.rb +2 -8
- data/db/migrate/20240303174340_fix_spree_stock_item_unique_index.rb +35 -0
- data/db/migrate/20240514105216_add_weight_and_dimension_units_to_spree_variants.rb +6 -0
- data/lib/generators/spree/custom_authentication/custom_authentication_generator.rb +23 -0
- data/lib/generators/spree/{custom_user → custom_authentication}/templates/authentication_helpers.rb.tt +1 -14
- data/lib/generators/spree/custom_user/custom_user_generator.rb +3 -8
- data/lib/generators/spree/custom_user/templates/current_user_helpers.rb.tt +15 -0
- data/lib/generators/spree/custom_user/templates/migration.rb.tt +2 -2
- data/lib/generators/spree/dummy/dummy_generator.rb +1 -6
- data/lib/generators/spree/dummy/templates/rails/database.yml +19 -21
- data/lib/generators/spree/dummy/templates/rails/test.rb +1 -1
- data/lib/generators/spree/install/templates/config/initializers/spree.rb +25 -0
- data/lib/spree/core/configuration.rb +11 -25
- data/lib/spree/core/controller_helpers/locale.rb +5 -1
- data/lib/spree/core/engine.rb +4 -1
- data/lib/spree/core/preferences/runtime_configuration.rb +43 -0
- data/lib/spree/core/product_duplicator.rb +2 -0
- data/lib/spree/core/product_filters.rb +9 -2
- data/lib/spree/core/runtime_configuration.rb +9 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core/webhooks.rb +13 -0
- data/lib/spree/core.rb +10 -1
- data/lib/spree/money.rb +38 -5
- data/lib/spree/testing_support/authorization_helpers.rb +3 -1
- data/lib/spree/testing_support/common_rake.rb +7 -18
- data/spree_core.gemspec +7 -7
- metadata +47 -50
- data/db/migrate/20220715120222_change_product_name_null_to_true.rb +0 -5
- data/db/migrate/20220718100948_change_taxon_name_null_to_true.rb +0 -5
- data/db/migrate/20220804073928_transfer_data_to_translatable_tables.rb +0 -66
- data/db/migrate/20230109094907_transfer_options_data_to_translatable_tables.rb +0 -58
- data/db/migrate/20230109110840_transfer_property_data_to_translatable_tables.rb +0 -59
- data/db/migrate/20230111122511_transfer_product_and_taxon_data_to_translatable_tables.rb +0 -82
- data/db/migrate/20230117120430_allow_null_taxonomy_name.rb +0 -5
- data/db/migrate/20230117121303_transfer_taxonomy_data_to_translatable_tables.rb +0 -11
- data/db/migrate/20230210142849_transfer_store_data_to_translatable_tables.rb +0 -11
- data/db/migrate/20230514162157_add_index_on_locale_and_permalink_to_spree_taxons.rb +0 -5
@@ -3,7 +3,7 @@ module Spree
|
|
3
3
|
acts_as_paranoid
|
4
4
|
|
5
5
|
include Spree::Metadata
|
6
|
-
if defined?(Spree::Webhooks)
|
6
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
7
7
|
include Spree::Webhooks::HasWebhooks
|
8
8
|
end
|
9
9
|
|
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
has_many :stock_movements, inverse_of: :stock_item
|
15
15
|
|
16
16
|
validates :stock_location, :variant, presence: true
|
17
|
-
validates :variant_id, uniqueness: { scope:
|
17
|
+
validates :variant_id, uniqueness: { scope: :stock_location_id }, unless: :deleted_at
|
18
18
|
|
19
19
|
validates :count_on_hand, numericality: {
|
20
20
|
greater_than_or_equal_to: 0,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class StockLocation < Spree::Base
|
3
3
|
include Spree::UniqueName
|
4
|
-
if defined?(Spree::Webhooks)
|
4
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
5
5
|
include Spree::Webhooks::HasWebhooks
|
6
6
|
end
|
7
7
|
if defined?(Spree::Security::StockLocations)
|
@@ -71,6 +71,11 @@ module Spree
|
|
71
71
|
stock_item(variant_id) || propagate_variant(variant)
|
72
72
|
end
|
73
73
|
|
74
|
+
# Returns the count on hand number for the variant
|
75
|
+
#
|
76
|
+
# @param variant Variant instance
|
77
|
+
#
|
78
|
+
# @return [Integer]
|
74
79
|
def count_on_hand(variant)
|
75
80
|
stock_item(variant).try(:count_on_hand)
|
76
81
|
end
|
data/app/models/spree/store.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class Store < Spree::Base
|
3
3
|
include Spree::TranslatableResource
|
4
|
-
if defined?(Spree::Webhooks)
|
4
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
5
5
|
include Spree::Webhooks::HasWebhooks
|
6
6
|
end
|
7
7
|
if defined?(Spree::Security::Stores)
|
@@ -11,7 +11,7 @@ module Spree
|
|
11
11
|
TRANSLATABLE_FIELDS = %i[name meta_description meta_keywords seo_title facebook
|
12
12
|
twitter instagram customer_support_email description
|
13
13
|
address contact_phone new_order_notifications_email].freeze
|
14
|
-
translates(*TRANSLATABLE_FIELDS)
|
14
|
+
translates(*TRANSLATABLE_FIELDS, column_fallback: true)
|
15
15
|
|
16
16
|
self::Translation.class_eval do
|
17
17
|
acts_as_paranoid
|
@@ -109,8 +109,6 @@ module Spree
|
|
109
109
|
|
110
110
|
after_commit :clear_cache
|
111
111
|
|
112
|
-
alias_attribute :contact_email, :customer_support_email
|
113
|
-
|
114
112
|
def self.current(url = nil)
|
115
113
|
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
116
114
|
`Spree::Store.current` is deprecated and will be removed in Spree 5.0
|
@@ -10,8 +10,17 @@ module Spree
|
|
10
10
|
|
11
11
|
validates :attachment,
|
12
12
|
content_type: VALID_CONTENT_TYPES,
|
13
|
-
dimension: { max: 256..256 },
|
14
|
-
aspect_ratio: :square,
|
15
13
|
size: { less_than_or_equal_to: 1.megabyte }
|
14
|
+
|
15
|
+
validates :attachment,
|
16
|
+
if: :is_png?,
|
17
|
+
dimension: { max: 256..256 },
|
18
|
+
aspect_ratio: :square
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def is_png?
|
23
|
+
attachment.content_type.in?('image/png')
|
24
|
+
end
|
16
25
|
end
|
17
26
|
end
|
data/app/models/spree/taxon.rb
CHANGED
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
include Spree::TranslatableResource
|
7
7
|
include Spree::TranslatableResourceSlug
|
8
8
|
include Spree::Metadata
|
9
|
-
if defined?(Spree::Webhooks)
|
9
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
10
10
|
include Spree::Webhooks::HasWebhooks
|
11
11
|
end
|
12
12
|
|
@@ -48,6 +48,8 @@ module Spree
|
|
48
48
|
after_update :sync_taxonomy_name
|
49
49
|
after_touch :touch_ancestors_and_taxonomy
|
50
50
|
|
51
|
+
has_one :store, through: :taxonomy
|
52
|
+
|
51
53
|
has_one :icon, as: :viewable, dependent: :destroy, class_name: 'Spree::TaxonImage'
|
52
54
|
|
53
55
|
scope :for_store, ->(store) { joins(:taxonomy).where(spree_taxonomies: { store_id: store.id }) }
|
@@ -58,7 +60,7 @@ module Spree
|
|
58
60
|
scope :for_stores, ->(stores) { joins(:taxonomy).where(spree_taxonomies: { store_id: stores.ids }) }
|
59
61
|
|
60
62
|
TRANSLATABLE_FIELDS = %i[name description permalink].freeze
|
61
|
-
translates(*TRANSLATABLE_FIELDS)
|
63
|
+
translates(*TRANSLATABLE_FIELDS, column_fallback: true)
|
62
64
|
|
63
65
|
self::Translation.class_eval do
|
64
66
|
alias_attribute :slug, :permalink
|
@@ -117,7 +119,21 @@ module Spree
|
|
117
119
|
|
118
120
|
# Creates permalink base for friendly_id
|
119
121
|
def set_permalink
|
120
|
-
|
122
|
+
if Spree.use_translations?
|
123
|
+
translations.each(&:set_permalink)
|
124
|
+
else
|
125
|
+
self.permalink = generate_slug
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def generate_slug
|
130
|
+
if parent.present?
|
131
|
+
[parent.permalink, (permalink.blank? ? name.to_url : permalink.split('/').last.to_url)].join('/')
|
132
|
+
elsif permalink.blank?
|
133
|
+
name.to_url
|
134
|
+
else
|
135
|
+
permalink.to_url
|
136
|
+
end
|
121
137
|
end
|
122
138
|
|
123
139
|
def active_products
|
@@ -150,7 +166,7 @@ module Spree
|
|
150
166
|
private
|
151
167
|
|
152
168
|
def sync_taxonomy_name
|
153
|
-
if
|
169
|
+
if saved_changes.key?(:name) && root?
|
154
170
|
return if taxonomy.name.to_s == name.to_s
|
155
171
|
|
156
172
|
taxonomy.update(name: name)
|
@@ -2,12 +2,12 @@ module Spree
|
|
2
2
|
class Taxonomy < Spree::Base
|
3
3
|
include Spree::TranslatableResource
|
4
4
|
include Spree::Metadata
|
5
|
-
if defined?(Spree::Webhooks)
|
5
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
6
6
|
include Spree::Webhooks::HasWebhooks
|
7
7
|
end
|
8
8
|
|
9
9
|
TRANSLATABLE_FIELDS = %i[name].freeze
|
10
|
-
translates(*TRANSLATABLE_FIELDS)
|
10
|
+
translates(*TRANSLATABLE_FIELDS, column_fallback: true)
|
11
11
|
|
12
12
|
acts_as_list
|
13
13
|
|
@@ -32,7 +32,7 @@ module Spree
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def set_root_taxon_name
|
35
|
-
return unless
|
35
|
+
return unless saved_changes.key?(:name)
|
36
36
|
return if name.to_s == root.name.to_s
|
37
37
|
|
38
38
|
root.update(name: name)
|
data/app/models/spree/variant.rb
CHANGED
@@ -5,7 +5,7 @@ module Spree
|
|
5
5
|
|
6
6
|
include Spree::MemoizedData
|
7
7
|
include Spree::Metadata
|
8
|
-
if defined?(Spree::Webhooks)
|
8
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
9
9
|
include Spree::Webhooks::HasWebhooks
|
10
10
|
end
|
11
11
|
|
@@ -122,9 +122,14 @@ module Spree
|
|
122
122
|
self.whitelisted_ransackable_scopes = %i(product_name_or_sku_cont search_by_product_name_or_sku)
|
123
123
|
|
124
124
|
def self.product_name_or_sku_cont(query)
|
125
|
-
|
126
|
-
|
127
|
-
|
125
|
+
if Spree.use_translations?
|
126
|
+
joins(:product).
|
127
|
+
join_translation_table(Product).
|
128
|
+
where("LOWER(#{Product.translation_table_alias}.name) LIKE LOWER(:query)
|
129
|
+
OR LOWER(sku) LIKE LOWER(:query)", query: "%#{query}%")
|
130
|
+
else
|
131
|
+
joins(:product).where("LOWER(#{Product.table_name}.name) LIKE LOWER(:query) OR LOWER(sku) LIKE LOWER(:query)", query: "%#{query}%")
|
132
|
+
end
|
128
133
|
end
|
129
134
|
|
130
135
|
def self.search_by_product_name_or_sku(query)
|
data/app/models/spree/zone.rb
CHANGED
@@ -9,6 +9,7 @@ module Spree
|
|
9
9
|
def call(address:, address_params:)
|
10
10
|
address_params[:country_id] ||= address.country_id
|
11
11
|
address_params = fill_country_and_state_ids(address_params)
|
12
|
+
address_params[:user_id] = address.user_id if address.user_id.present?
|
12
13
|
|
13
14
|
if address&.editable?
|
14
15
|
address.update(address_params) ? success(address) : failure(address)
|
@@ -4,22 +4,24 @@ module Spree
|
|
4
4
|
prepend Spree::ServiceModule::Base
|
5
5
|
|
6
6
|
def call
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
Spree::Webhooks.disable_webhooks do
|
8
|
+
# GEO
|
9
|
+
Countries.call
|
10
|
+
States.call
|
11
|
+
Zones.call
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
# user roles
|
14
|
+
Roles.call
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
# additional data
|
17
|
+
DefaultReimbursementTypes.call
|
18
|
+
ShippingCategories.call
|
19
|
+
StoreCreditCategories.call
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
# store & stock location
|
22
|
+
Stores.call
|
23
|
+
StockLocations.call
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -7,7 +7,7 @@ module Spree
|
|
7
7
|
default_store = Spree::Store.default
|
8
8
|
|
9
9
|
if default_store.persisted?
|
10
|
-
default_store.update!(
|
10
|
+
default_store.update!(default_country: Spree::Country.first)
|
11
11
|
else
|
12
12
|
Spree::Store.new do |s|
|
13
13
|
s.name = 'Spree Demo Site'
|
@@ -16,7 +16,7 @@ module Spree
|
|
16
16
|
s.mail_from_address = 'no-reply@example.com'
|
17
17
|
s.customer_support_email = 'support@example.com'
|
18
18
|
s.default_currency = 'USD'
|
19
|
-
s.
|
19
|
+
s.default_country = Spree::Country.first
|
20
20
|
s.default_locale = I18n.locale
|
21
21
|
s.seo_title = 'Spree Commerce Demo Shop'
|
22
22
|
s.meta_description = 'This is the new Spree UX DEMO | OVERVIEW: http://bit.ly/new-spree-ux | DOCS: http://bit.ly/spree-ux-customization-docs | CONTACT: https://spreecommerce.org/contact/'
|
data/config/locales/en.yml
CHANGED
@@ -1038,8 +1038,8 @@ en:
|
|
1038
1038
|
go_to_previous_menu: Go to previous menu
|
1039
1039
|
log_in: LOG IN
|
1040
1040
|
log_out: LOG OUT
|
1041
|
-
my_account:
|
1042
|
-
my_orders:
|
1041
|
+
my_account: My Account
|
1042
|
+
my_orders: My Orders
|
1043
1043
|
show_menu: Show menu
|
1044
1044
|
show_search: Show search
|
1045
1045
|
show_user_menu: Show user menu
|
@@ -1234,14 +1234,6 @@ en:
|
|
1234
1234
|
payment_type: Payment type
|
1235
1235
|
payment_updated: Payment Updated
|
1236
1236
|
payments: Payments
|
1237
|
-
pdp:
|
1238
|
-
checkout: Checkout
|
1239
|
-
description: Description
|
1240
|
-
details: Details
|
1241
|
-
products_included_in_promotion: Products included in the promotion
|
1242
|
-
quantity: Quantity
|
1243
|
-
view_cart: View cart
|
1244
|
-
you_may_also_like: You may also like
|
1245
1237
|
percent: Percent
|
1246
1238
|
percent_per_item: Percent Per Item
|
1247
1239
|
permalink: Permalink
|
@@ -1251,32 +1243,6 @@ en:
|
|
1251
1243
|
place_order: Place Order
|
1252
1244
|
please_define_payment_methods: Please define some payment methods first.
|
1253
1245
|
please_enter_reasonable_quantity: Please enter a reasonable quantity.
|
1254
|
-
plp:
|
1255
|
-
best_selling: BEST SELLING
|
1256
|
-
clear_all: CLEAR ALL
|
1257
|
-
collection: COLLECTION
|
1258
|
-
color: COLOR
|
1259
|
-
done: DONE
|
1260
|
-
default: DEFAULT
|
1261
|
-
filter_by: FILTER BY
|
1262
|
-
newest_first: NEWEST FIRST
|
1263
|
-
no_results: No results
|
1264
|
-
no_results_found: No results found
|
1265
|
-
not_found_filters1: We couldn’t find a match for these filters.
|
1266
|
-
not_found_filters2: Please try another choose.
|
1267
|
-
not_found_text1: We couldn’t find products for '%{keywords}'.
|
1268
|
-
not_found_text2: Please try another search.
|
1269
|
-
price: price
|
1270
|
-
price_high_to_low: PRICE (HIGH - LOW)
|
1271
|
-
price_low_to_high: PRICE (LOW - HIGH)
|
1272
|
-
name_a_z: NAME (A-Z)
|
1273
|
-
name_z_a: NAME (Z-A)
|
1274
|
-
result: RESULT
|
1275
|
-
results_for: RESULTS FOR
|
1276
|
-
size: SIZE
|
1277
|
-
sort_by: SORT BY
|
1278
|
-
top_sellers: TOP SELLERS
|
1279
|
-
type: TYPE
|
1280
1246
|
populate_get_error: Something went wrong. Please try adding the item again.
|
1281
1247
|
powered_by: Powered by
|
1282
1248
|
pre_tax_refund_amount: Pre-Tax Refund Amount
|
data/config/routes.rb
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
# see: https://github.com/rails/rails/issues/34872
|
3
3
|
Rails.application.routes.draw do
|
4
4
|
direct :cdn_image do |model, options|
|
5
|
+
options[:host] = Spree.cdn_host if Spree.cdn_host.present?
|
6
|
+
options[:host] ||= Rails.application.routes.default_url_options[:host]
|
7
|
+
|
8
|
+
options[:only_path] = true if options[:host].blank?
|
9
|
+
|
5
10
|
if model.blob.service_name == 'cloudinary' && defined?(Cloudinary)
|
6
11
|
if model.class.method_defined?(:has_mvariation)
|
7
12
|
Cloudinary::Utils.cloudinary_url(model.blob.key,
|
@@ -17,10 +22,7 @@ Rails.application.routes.draw do
|
|
17
22
|
:rails_service_blob_proxy,
|
18
23
|
model.signed_id,
|
19
24
|
model.filename,
|
20
|
-
options
|
21
|
-
host: Spree.cdn_host || Rails.application.routes.default_url_options[:host],
|
22
|
-
port: Rails.application.routes.default_url_options[:port]
|
23
|
-
)
|
25
|
+
options
|
24
26
|
)
|
25
27
|
else
|
26
28
|
signed_blob_id = model.blob.signed_id
|
@@ -32,10 +34,7 @@ Rails.application.routes.draw do
|
|
32
34
|
signed_blob_id,
|
33
35
|
variation_key,
|
34
36
|
filename,
|
35
|
-
options
|
36
|
-
host: Spree.cdn_host || Rails.application.routes.default_url_options[:host],
|
37
|
-
port: Rails.application.routes.default_url_options[:port]
|
38
|
-
)
|
37
|
+
options
|
39
38
|
)
|
40
39
|
end
|
41
40
|
end
|
@@ -1,32 +1,5 @@
|
|
1
1
|
class CreateStockItemStockLocationIdVariantIdCoalesceDeletedAtUniqueIndex < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
|
-
|
4
|
-
reversible do |dir|
|
5
|
-
dir.up do
|
6
|
-
execute <<-SQL
|
7
|
-
CREATE UNIQUE INDEX stock_item_by_loc_var_id_deleted_at
|
8
|
-
ON spree_stock_items(
|
9
|
-
stock_location_id,
|
10
|
-
variant_id,
|
11
|
-
(COALESCE(deleted_at, CAST('1970-01-01' AS #{deleted_at_data_type})))
|
12
|
-
);
|
13
|
-
SQL
|
14
|
-
end
|
15
|
-
|
16
|
-
dir.down do
|
17
|
-
remove_index :spree_stock_items, name: :stock_item_by_loc_var_id_deleted_at
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def deleted_at_data_type
|
25
|
-
case ActiveRecord::Base.connection.adapter_name
|
26
|
-
when 'Mysql2'
|
27
|
-
'DATETIME'
|
28
|
-
when 'PostgreSQL'
|
29
|
-
'TIMESTAMP'
|
30
|
-
end
|
3
|
+
# this migration was broken and is fixed in the following migration
|
31
4
|
end
|
32
5
|
end
|
@@ -9,7 +9,6 @@ class CreateProductPropertyTranslations < ActiveRecord::Migration[6.1]
|
|
9
9
|
create_table :spree_product_property_translations do |t|
|
10
10
|
# Translated attribute(s)
|
11
11
|
t.string :value
|
12
|
-
t.string :filter_param
|
13
12
|
|
14
13
|
t.string :locale, null: false
|
15
14
|
t.references :spree_product_property, null: false, foreign_key: true, index: false
|
@@ -8,9 +8,7 @@ class CreatePropertyTranslations < ActiveRecord::Migration[6.1]
|
|
8
8
|
else
|
9
9
|
create_table :spree_property_translations do |t|
|
10
10
|
# Translated attribute(s)
|
11
|
-
t.string :name
|
12
11
|
t.string :presentation
|
13
|
-
t.string :filter_param
|
14
12
|
|
15
13
|
t.string :locale, null: false
|
16
14
|
t.references :spree_property, null: false, foreign_key: true, index: false
|
@@ -1,15 +1,9 @@
|
|
1
1
|
class BackfillFriendlyIdSlugLocale < ActiveRecord::Migration[6.1]
|
2
|
-
DEFAULT_LOCALE = 'en'
|
3
|
-
|
4
2
|
def up
|
5
|
-
|
6
|
-
UPDATE friendly_id_slugs SET locale = '#{DEFAULT_LOCALE}'
|
7
|
-
")
|
3
|
+
FriendlyId::Slug.unscoped.update_all(locale: Spree::Store.default.default_locale)
|
8
4
|
end
|
9
5
|
|
10
6
|
def down
|
11
|
-
|
12
|
-
UPDATE friendly_id_slugs SET locale = NULL
|
13
|
-
")
|
7
|
+
FriendlyId::Slug.unscoped.update_all(locale: nil)
|
14
8
|
end
|
15
9
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class FixSpreeStockItemUniqueIndex < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
remove_index :spree_stock_items, name: 'stock_item_by_loc_var_id_deleted_at' if index_exists?(:spree_stock_items, [:stock_location_id, :variant_id], name: 'stock_item_by_loc_var_id_deleted_at')
|
4
|
+
|
5
|
+
unless index_exists?(:spree_stock_items, ['variant_id', 'stock_location_id'], name: 'index_spree_stock_items_unique_without_deleted_at')
|
6
|
+
# MySQL doesn't support partial indexes
|
7
|
+
if ActiveRecord::Base.connection.adapter_name == 'Mysql2'
|
8
|
+
reversible do |dir|
|
9
|
+
dir.up do
|
10
|
+
execute <<-SQL
|
11
|
+
CREATE UNIQUE INDEX index_spree_stock_items_unique_without_deleted_at
|
12
|
+
ON spree_stock_items(
|
13
|
+
stock_location_id,
|
14
|
+
variant_id,
|
15
|
+
(COALESCE(deleted_at, CAST('1970-01-01' AS DATETIME)))
|
16
|
+
);
|
17
|
+
SQL
|
18
|
+
end
|
19
|
+
|
20
|
+
dir.down do
|
21
|
+
remove_index :spree_stock_items, name: :index_spree_stock_items_unique_without_deleted_at
|
22
|
+
end
|
23
|
+
end
|
24
|
+
else
|
25
|
+
add_index(
|
26
|
+
:spree_stock_items,
|
27
|
+
['variant_id', 'stock_location_id'],
|
28
|
+
name: 'index_spree_stock_items_unique_without_deleted_at',
|
29
|
+
unique: true,
|
30
|
+
where: 'deleted_at IS NULL',
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Spree
|
2
|
+
class CustomAuthenticationGenerator < Rails::Generators::Base
|
3
|
+
desc 'Set up a Spree installation with a custom authentication helpers'
|
4
|
+
|
5
|
+
def self.source_paths
|
6
|
+
paths = superclass.source_paths
|
7
|
+
paths << File.expand_path('templates', __dir__)
|
8
|
+
paths.flatten
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate
|
12
|
+
template 'authentication_helpers.rb.tt', 'lib/spree/authentication_helpers.rb'
|
13
|
+
|
14
|
+
file_action = File.exist?('config/initializers/spree.rb') ? :append_file : :create_file
|
15
|
+
send(file_action, 'config/initializers/spree.rb') do
|
16
|
+
%Q{
|
17
|
+
Rails.application.config.to_prepare do
|
18
|
+
require_dependency 'spree/authentication_helpers'
|
19
|
+
end\n}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,14 +1,4 @@
|
|
1
1
|
module Spree
|
2
|
-
module CurrentUserHelpers
|
3
|
-
def self.included(receiver)
|
4
|
-
receiver.send :helper_method, :spree_current_user
|
5
|
-
end
|
6
|
-
|
7
|
-
def spree_current_user
|
8
|
-
current_user
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
2
|
module AuthenticationHelpers
|
13
3
|
def self.included(receiver)
|
14
4
|
receiver.send :helper_method, :spree_login_path
|
@@ -30,7 +20,4 @@ module Spree
|
|
30
20
|
end
|
31
21
|
end
|
32
22
|
|
33
|
-
ApplicationController.include Spree::AuthenticationHelpers
|
34
|
-
ApplicationController.include Spree::CurrentUserHelpers
|
35
|
-
|
36
|
-
Spree::Api::BaseController.include Spree::CurrentUserHelpers
|
23
|
+
ApplicationController.include Spree::AuthenticationHelpers if defined?(ApplicationController)
|