solidus_core 3.1.7 → 3.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17023a55872c98530a41d6e9dcfa86f9cb2273d6bda4f90138414fef73faf408
4
- data.tar.gz: 025eea8e4777138faceebbd8c8747a1529c0d56218ac908e2a42c12ef69da5b0
3
+ metadata.gz: fd88c98f5da37d9a89e981aad39979998349f0e2405a4a7095a8f75f4d3839f8
4
+ data.tar.gz: 656beea8141300d09b62b4970dccd7691556112597a891a4f0d1821a67914ea3
5
5
  SHA512:
6
- metadata.gz: 10b6f6770fdb30bd9b2269731fbc749c32221f37c8c04c1034bf3a8621869c52df31669d80cf2d47d5f4b04eaa25305ab36f1dcda72a3aaa06fa53eda0f492b4
7
- data.tar.gz: 62b8b420c98f055c40faea148d36769a33d7cb3e6a878dcc0a930ecf0b3b40195f6421a4e2d7150c4086770f4bdb42c2bcdca0a4c947f6bd8ab42903c799bda0
6
+ metadata.gz: 44d04ac1151fd4f7f2ac20b7f117e500b76be1d39fd2ad5ef72654dca8749bd9dd42eb9acd402adf519d2769d7099b8d44977ccf0a906089c10315675b22cad1
7
+ data.tar.gz: 93ff18fdf9856b60aec7f484bd468db70c67bd9e446e7fbedf383ff88f21f59fb261d0c53b7db1f46c0a8848f133fb032258ae7d57c968d485503abc248fb606
@@ -16,10 +16,12 @@ module Spree
16
16
 
17
17
  # Returns `#prices` prioritized for being considered as default price
18
18
  #
19
+ # @deprecated
19
20
  # @return [ActiveRecord::Relation<Spree::Price>]
20
21
  def currently_valid_prices
21
22
  prices.currently_valid
22
23
  end
24
+ deprecate :currently_valid_prices, deprecator: Spree::Deprecation
23
25
 
24
26
  # Returns {#default_price} or builds it from {Spree::Variant.default_price_attributes}
25
27
  #
@@ -33,7 +35,7 @@ module Spree
33
35
  # Select from {#prices} the one to be considered as the default
34
36
  #
35
37
  # This method works with the in-memory association, so non-persisted prices
36
- # are taken into account. Discarded prices are also considered.
38
+ # are taken into account.
37
39
  #
38
40
  # A price is a candidate to be considered as the default when it meets
39
41
  # {Spree::Variant.default_price_attributes} criteria. When more than one candidate is
@@ -44,37 +46,11 @@ module Spree
44
46
  # @return [Spree::Price, nil]
45
47
  # @see Spree::Variant.default_price_attributes
46
48
  def default_price
47
- prioritized_default(
48
- prices_meeting_criteria_to_be_default(
49
- (prices + prices.with_discarded).uniq
50
- )
51
- )
49
+ price_selector.price_for_options(Spree::Config.default_pricing_options)
52
50
  end
53
51
 
54
52
  def has_default_price?
55
53
  default_price.present? && !default_price.discarded?
56
54
  end
57
-
58
- private
59
-
60
- def prices_meeting_criteria_to_be_default(prices)
61
- criteria = self.class.default_price_attributes.transform_keys(&:to_s)
62
- prices.select do |price|
63
- contender = price.attributes.slice(*criteria.keys)
64
- criteria == contender
65
- end
66
- end
67
-
68
- def prioritized_default(prices)
69
- prices.min do |prev, succ|
70
- contender_one, contender_two = [succ, prev].map do |item|
71
- [
72
- item.updated_at || Time.zone.now,
73
- item.id || Float::INFINITY
74
- ]
75
- end
76
- contender_one <=> contender_two
77
- end
78
- end
79
55
  end
80
56
  end
@@ -18,7 +18,7 @@ module Spree
18
18
  has_many :stock_locations, through: :user_stock_locations
19
19
 
20
20
  has_many :spree_orders, foreign_key: "user_id", class_name: "Spree::Order"
21
- has_many :orders, foreign_key: "user_id", class_name: "Spree::Order", dependent: :restrict_with_exception
21
+ has_many :orders, foreign_key: "user_id", class_name: "Spree::Order"
22
22
 
23
23
  has_many :store_credits, -> { includes(:credit_type) }, foreign_key: "user_id", class_name: "Spree::StoreCredit"
24
24
  has_many :store_credit_events, through: :store_credits
@@ -27,6 +27,7 @@ module Spree
27
27
  has_many :wallet_payment_sources, foreign_key: 'user_id', class_name: 'Spree::WalletPaymentSource', inverse_of: :user
28
28
 
29
29
  after_create :auto_generate_spree_api_key
30
+ before_destroy :check_for_deletion
30
31
 
31
32
  include Spree::RansackableAttributes unless included_modules.include?(Spree::RansackableAttributes)
32
33
 
@@ -76,5 +77,23 @@ module Spree
76
77
  currency: currency,
77
78
  )
78
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
+ private
94
+
95
+ def check_for_deletion
96
+ raise ActiveRecord::DeleteRestrictionError unless can_be_deleted?
97
+ end
79
98
  end
80
99
  end
@@ -55,7 +55,7 @@ module Spree
55
55
 
56
56
  def display_country
57
57
  if country_iso
58
- "#{country_iso} (#{country.name})"
58
+ "#{country_iso} (#{I18n.t(country_iso, scope: [:spree, :country_names])})"
59
59
  else
60
60
  I18n.t(:any_country, scope: [:spree, :admin, :prices])
61
61
  end
@@ -39,12 +39,29 @@ module Spree
39
39
  # @param [Spree::Variant::PricingOptions] price_options Pricing Options to abide by
40
40
  # @return [Spree::Price, nil] The most specific price for this set of pricing options.
41
41
  def price_for_options(price_options)
42
- variant.currently_valid_prices.detect do |price|
42
+ sorted_prices_for(variant).detect do |price|
43
43
  (price.country_iso == price_options.desired_attributes[:country_iso] ||
44
44
  price.country_iso.nil?
45
45
  ) && price.currency == price_options.desired_attributes[:currency]
46
46
  end
47
47
  end
48
+
49
+ private
50
+
51
+ # Returns `#prices` prioritized for being considered as default price
52
+ #
53
+ # @return [Array<Spree::Price>]
54
+ def sorted_prices_for(variant)
55
+ variant.prices.select do |price|
56
+ variant.discarded? || price.kept?
57
+ end.sort_by do |price|
58
+ [
59
+ price.country_iso.nil? ? 0 : 1,
60
+ price.updated_at || Time.zone.now,
61
+ price.id || Float::INFINITY,
62
+ ]
63
+ end.reverse
64
+ end
48
65
  end
49
66
  end
50
67
  end
@@ -23,7 +23,6 @@ module Spree
23
23
  after_discard do
24
24
  stock_items.discard_all
25
25
  images.destroy_all
26
- prices.discard_all
27
26
  end
28
27
 
29
28
  attr_writer :rebuild_vat_prices
@@ -52,6 +51,7 @@ module Spree
52
51
  has_many :images, -> { order(:position) }, as: :viewable, dependent: :destroy, class_name: "Spree::Image"
53
52
 
54
53
  has_many :prices,
54
+ -> { with_discarded },
55
55
  class_name: 'Spree::Price',
56
56
  dependent: :destroy,
57
57
  inverse_of: :variant,
@@ -762,6 +762,10 @@ en:
762
762
  not_saved:
763
763
  one: '1 error prohibited this %{resource} from being saved:'
764
764
  other: "%{count} errors prohibited this %{resource} from being saved:"
765
+ number:
766
+ percentage:
767
+ format:
768
+ precision: 1
765
769
  spree:
766
770
  abbreviation: Abbreviation
767
771
  accept: Accept
@@ -1004,6 +1008,8 @@ en:
1004
1008
  use_product_tax_category: Use Product Tax Category
1005
1009
  new:
1006
1010
  new_variant: New Variant
1011
+ table:
1012
+ no_variants_found: No variants found for '%{term}'
1007
1013
  table_filter:
1008
1014
  show_deleted: Show Deleted Variants
1009
1015
  administration: Administration
@@ -1170,10 +1176,257 @@ en:
1170
1176
  country_based: Country Based
1171
1177
  country_name: Name
1172
1178
  country_names:
1179
+ AD: Andorra
1180
+ AE: United Arab Emirates
1181
+ AF: Afghanistan
1182
+ AG: Antigua and Barbuda
1183
+ AI: Anguilla
1184
+ AL: Albania
1185
+ AM: Armenia
1186
+ AO: Angola
1187
+ AQ: Antarctica
1188
+ AR: Argentina
1189
+ AS: American Samoa
1190
+ AT: Austria
1191
+ AU: Australia
1192
+ AW: Aruba
1193
+ AX: Åland Islands
1194
+ AZ: Azerbaijan
1195
+ BA: Bosnia and Herzegovina
1196
+ BB: Barbados
1197
+ BD: Bangladesh
1198
+ BE: Belgium
1199
+ BF: Burkina Faso
1200
+ BG: Bulgaria
1201
+ BH: Bahrain
1202
+ BI: Burundi
1203
+ BJ: Benin
1204
+ BL: Saint Barthélemy
1205
+ BM: Bermuda
1206
+ BN: Brunei Darussalam
1207
+ BO: Bolivia, Plurinational State of
1208
+ BQ: Bonaire, Sint Eustatius and Saba
1209
+ BR: Brazil
1210
+ BS: Bahamas
1211
+ BT: Bhutan
1212
+ BV: Bouvet Island
1213
+ BW: Botswana
1214
+ BY: Belarus
1215
+ BZ: Belize
1173
1216
  CA: Canada
1217
+ CC: Cocos (Keeling) Islands
1218
+ CD: Congo, The Democratic Republic of the
1219
+ CF: Central African Republic
1220
+ CG: Congo
1221
+ CH: Switzerland
1222
+ CI: Côte d'Ivoire
1223
+ CK: Cook Islands
1224
+ CL: Chile
1225
+ CM: Cameroon
1226
+ CN: China
1227
+ CO: Colombia
1228
+ CR: Costa Rica
1229
+ CU: Cuba
1230
+ CV: Cabo Verde
1231
+ CW: Curaçao
1232
+ CX: Christmas Island
1233
+ CY: Cyprus
1234
+ CZ: Czechia
1235
+ DE: Germany
1236
+ DJ: Djibouti
1237
+ DK: Denmark
1238
+ DM: Dominica
1239
+ DO: Dominican Republic
1240
+ DZ: Algeria
1241
+ EC: Ecuador
1242
+ EE: Estonia
1243
+ EG: Egypt
1244
+ EH: Western Sahara
1245
+ ER: Eritrea
1246
+ ES: Spain
1247
+ ET: Ethiopia
1248
+ FI: Finland
1249
+ FJ: Fiji
1250
+ FK: Falkland Islands (Malvinas)
1251
+ FM: Micronesia, Federated States of
1252
+ FO: Faroe Islands
1253
+ FR: France
1174
1254
  FRA: France
1255
+ GA: Gabon
1256
+ GB: United Kingdom
1257
+ GD: Grenada
1258
+ GE: Georgia
1259
+ GF: French Guiana
1260
+ GG: Guernsey
1261
+ GH: Ghana
1262
+ GI: Gibraltar
1263
+ GL: Greenland
1264
+ GM: Gambia
1265
+ GN: Guinea
1266
+ GP: Guadeloupe
1267
+ GQ: Equatorial Guinea
1268
+ GR: Greece
1269
+ GS: South Georgia and the South Sandwich Islands
1270
+ GT: Guatemala
1271
+ GU: Guam
1272
+ GW: Guinea-Bissau
1273
+ GY: Guyana
1274
+ HK: Hong Kong
1275
+ HM: Heard Island and McDonald Islands
1276
+ HN: Honduras
1277
+ HR: Croatia
1278
+ HT: Haiti
1279
+ HU: Hungary
1280
+ ID: Indonesia
1281
+ IE: Ireland
1282
+ IL: Israel
1283
+ IM: Isle of Man
1284
+ IN: India
1285
+ IO: British Indian Ocean Territory
1286
+ IQ: Iraq
1287
+ IR: Iran, Islamic Republic of
1288
+ IS: Iceland
1289
+ IT: Italy
1175
1290
  ITA: Italy
1291
+ JE: Jersey
1292
+ JM: Jamaica
1293
+ JO: Jordan
1294
+ JP: Japan
1295
+ KE: Kenya
1296
+ KG: Kyrgyzstan
1297
+ KH: Cambodia
1298
+ KI: Kiribati
1299
+ KM: Comoros
1300
+ KN: Saint Kitts and Nevis
1301
+ KP: Korea, Democratic People's Republic of
1302
+ KR: Korea, Republic of
1303
+ KW: Kuwait
1304
+ KY: Cayman Islands
1305
+ KZ: Kazakhstan
1306
+ LA: Lao People's Democratic Republic
1307
+ LB: Lebanon
1308
+ LC: Saint Lucia
1309
+ LI: Liechtenstein
1310
+ LK: Sri Lanka
1311
+ LR: Liberia
1312
+ LS: Lesotho
1313
+ LT: Lithuania
1314
+ LU: Luxembourg
1315
+ LV: Latvia
1316
+ LY: Libya
1317
+ MA: Morocco
1318
+ MC: Monaco
1319
+ MD: Moldova, Republic of
1320
+ ME: Montenegro
1321
+ MF: Saint Martin (French part)
1322
+ MG: Madagascar
1323
+ MH: Marshall Islands
1324
+ MK: North Macedonia
1325
+ ML: Mali
1326
+ MM: Myanmar
1327
+ MN: Mongolia
1328
+ MO: Macao
1329
+ MP: Northern Mariana Islands
1330
+ MQ: Martinique
1331
+ MR: Mauritania
1332
+ MS: Montserrat
1333
+ MT: Malta
1334
+ MU: Mauritius
1335
+ MV: Maldives
1336
+ MW: Malawi
1337
+ MX: Mexico
1338
+ MY: Malaysia
1339
+ MZ: Mozambique
1340
+ NA: Namibia
1341
+ NC: New Caledonia
1342
+ NE: Niger
1343
+ NF: Norfolk Island
1344
+ NG: Nigeria
1345
+ NI: Nicaragua
1346
+ NL: Netherlands
1347
+ 'NO': Norway
1348
+ NP: Nepal
1349
+ NR: Nauru
1350
+ NU: Niue
1351
+ NZ: New Zealand
1352
+ OM: Oman
1353
+ PA: Panama
1354
+ PE: Peru
1355
+ PF: French Polynesia
1356
+ PG: Papua New Guinea
1357
+ PH: Philippines
1358
+ PK: Pakistan
1359
+ PL: Poland
1360
+ PM: Saint Pierre and Miquelon
1361
+ PN: Pitcairn
1362
+ PR: Puerto Rico
1363
+ PS: Palestine, State of
1364
+ PT: Portugal
1365
+ PW: Palau
1366
+ PY: Paraguay
1367
+ QA: Qatar
1368
+ RE: Réunion
1369
+ RO: Romania
1370
+ RS: Serbia
1371
+ RU: Russia
1372
+ RW: Rwanda
1373
+ SA: Saudi Arabia
1374
+ SB: Solomon Islands
1375
+ SC: Seychelles
1376
+ SD: Sudan
1377
+ SE: Sweden
1378
+ SG: Singapore
1379
+ SH: Saint Helena, Ascension and Tristan da Cunha
1380
+ SI: Slovenia
1381
+ SJ: Svalbard and Jan Mayen
1382
+ SK: Slovakia
1383
+ SL: Sierra Leone
1384
+ SM: San Marino
1385
+ SN: Senegal
1386
+ SO: Somalia
1387
+ SR: Suriname
1388
+ SS: South Sudan
1389
+ ST: Sao Tome and Principe
1390
+ SV: El Salvador
1391
+ SX: Sint Maarten (Dutch part)
1392
+ SY: Syrian Arab Republic
1393
+ SZ: Eswatini
1394
+ TC: Turks and Caicos Islands
1395
+ TD: Chad
1396
+ TF: French Southern Territories
1397
+ TG: Togo
1398
+ TH: Thailand
1399
+ TJ: Tajikistan
1400
+ TK: Tokelau
1401
+ TL: Timor-Leste
1402
+ TM: Turkmenistan
1403
+ TN: Tunisia
1404
+ TO: Tonga
1405
+ TR: Turkey
1406
+ TT: Trinidad and Tobago
1407
+ TV: Tuvalu
1408
+ TW: Taiwan
1409
+ TZ: Tanzania, United Republic of
1410
+ UA: Ukraine
1411
+ UG: Uganda
1412
+ UM: United States Minor Outlying Islands
1176
1413
  US: United States of America
1414
+ UY: Uruguay
1415
+ UZ: Uzbekistan
1416
+ VA: Holy See (Vatican City State)
1417
+ VC: Saint Vincent and the Grenadines
1418
+ VE: Venezuela, Bolivarian Republic of
1419
+ VG: Virgin Islands, British
1420
+ VI: Virgin Islands, U.S.
1421
+ VN: Vietnam
1422
+ VU: Vanuatu
1423
+ WF: Wallis and Futuna
1424
+ WS: Samoa
1425
+ YE: Yemen
1426
+ YT: Mayotte
1427
+ ZA: South Africa
1428
+ ZM: Zambia
1429
+ ZW: Zimbabwe
1177
1430
  coupon: Coupon
1178
1431
  coupon_code: Coupon code
1179
1432
  coupon_code_already_applied: The coupon code has already been applied to this
@@ -21,6 +21,7 @@ require "spree/core/search/base"
21
21
  require "spree/core/search/variant"
22
22
  require 'spree/preferences/configuration'
23
23
  require 'spree/core/environment'
24
+ require 'rails/gem_version'
24
25
 
25
26
  module Spree
26
27
  class AppConfiguration < Preferences::Configuration
@@ -481,7 +482,7 @@ module Spree
481
482
  # @!attribute [rw] image_attachment_module
482
483
  # @return [Module] a module that can be included into Spree::Image to allow attachments
483
484
  # Enumerable of images adhering to the present_image_class interface
484
- class_name_attribute :image_attachment_module, default: 'Spree::Image::ActiveStorageAttachment'
485
+ class_name_attribute :image_attachment_module, default: Rails.gem_version >= Gem::Version.new("6.1.0") ? "Spree::Image::ActiveStorageAttachment" : "Spree::Image::PaperclipAttachment"
485
486
 
486
487
  # @!attribute [rw] allowed_image_mime_types
487
488
  #
@@ -539,7 +540,7 @@ module Spree
539
540
  # @!attribute [rw] taxon_attachment_module
540
541
  # @return [Module] a module that can be included into Spree::Taxon to allow attachments
541
542
  # Enumerable of taxons adhering to the present_taxon_class interface
542
- class_name_attribute :taxon_attachment_module, default: 'Spree::Taxon::ActiveStorageAttachment'
543
+ class_name_attribute :taxon_attachment_module, default: Rails.gem_version >= Gem::Version.new("6.1.0") ? "Spree::Taxon::ActiveStorageAttachment" : "Spree::Taxon::PaperclipAttachment"
543
544
 
544
545
  # Allows providing your own class instance for generating order numbers.
545
546
  #
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "3.1.7"
4
+ VERSION = "3.1.9"
5
5
 
6
6
  def self.solidus_version
7
7
  VERSION
@@ -10,6 +10,9 @@ module Spree
10
10
  #
11
11
  # A class including Preferable must implement #preferences which should return
12
12
  # an object responding to .fetch(key), []=(key, val), and .delete(key).
13
+ # If #preferences is initialized with `default_preferences` and one of the
14
+ # preferences is another preference, it will cause a stack level too deep error.
15
+ # To avoid it do not memoize #preferences.
13
16
  #
14
17
  # It may also define a `#context_for_default` method. It should return an
15
18
  # array with the arguments to be provided to a proc used as the `default:`
@@ -111,6 +114,8 @@ module Spree
111
114
  end
112
115
 
113
116
  # @return [Hash{Symbol => Object}] Default for all preferences defined on this class
117
+ # This may raise an infinite loop error if any of the defaults are
118
+ # dependent on other preferences defaults.
114
119
  def default_preferences
115
120
  Hash[
116
121
  defined_preferences.map do |preference|
@@ -75,7 +75,7 @@ module Spree::Preferences
75
75
  # is a pending preference before going to default
76
76
  define_method preference_getter_method(name) do
77
77
  value = preferences.fetch(name) do
78
- default.call(*context_for_default)
78
+ instance_exec(*context_for_default, &default)
79
79
  end
80
80
  value = preference_encryptor.decrypt(value) if preference_encryptor.present?
81
81
  value
@@ -92,7 +92,7 @@ module Spree::Preferences
92
92
  end
93
93
 
94
94
  define_method preference_default_getter_method(name) do
95
- default.call(*context_for_default)
95
+ instance_exec(*context_for_default, &default)
96
96
  end
97
97
 
98
98
  define_method preference_type_getter_method(name) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.7
4
+ version: 3.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-15 00:00:00.000000000 Z
11
+ date: 2023-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -974,8 +974,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
974
974
  - !ruby/object:Gem::Version
975
975
  version: 1.8.23
976
976
  requirements: []
977
- rubygems_version: 3.1.2
978
- signing_key:
977
+ rubygems_version: 3.3.7
978
+ signing_key:
979
979
  specification_version: 4
980
980
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.
981
981
  test_files: []