spree_core 2.4.0.rc2 → 2.4.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/spree/products_helper.rb +7 -8
- data/app/models/spree/adjustment.rb +7 -2
- data/app/models/spree/classification.rb +1 -1
- data/app/models/spree/exchange.rb +4 -0
- data/app/models/spree/gateway/bogus.rb +3 -2
- data/app/models/spree/inventory_unit.rb +1 -1
- data/app/models/spree/item_adjustments.rb +7 -3
- data/app/models/spree/line_item.rb +5 -0
- data/app/models/spree/order.rb +3 -3
- data/app/models/spree/order_contents.rb +11 -14
- data/app/models/spree/payment.rb +7 -3
- data/app/models/spree/payment_method/check.rb +2 -0
- data/app/models/spree/payment_method.rb +5 -1
- data/app/models/spree/product.rb +11 -8
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +3 -2
- data/app/models/spree/promotion/actions/create_line_items.rb +1 -0
- data/app/models/spree/promotion.rb +2 -2
- data/app/models/spree/promotion_handler/coupon.rb +5 -1
- data/app/models/spree/property.rb +0 -7
- data/app/models/spree/prototype.rb +1 -0
- data/app/models/spree/reimbursement.rb +1 -1
- data/app/models/spree/reimbursement_tax_calculator.rb +7 -1
- data/app/models/spree/return_authorization.rb +1 -1
- data/app/models/spree/shipping_category.rb +2 -2
- data/app/models/spree/shipping_method_category.rb +1 -1
- data/app/models/spree/stock/package.rb +6 -0
- data/app/models/spree/stock_item.rb +2 -2
- data/app/models/spree/stock_location.rb +1 -1
- data/app/models/spree/store.rb +1 -1
- data/app/models/spree/tax_category.rb +2 -2
- data/app/models/spree/tax_rate.rb +7 -4
- data/app/models/spree/taxon.rb +7 -3
- data/app/models/spree/variant.rb +5 -5
- data/app/models/spree/zone.rb +15 -17
- data/app/models/spree/zone_member.rb +1 -1
- data/config/initializers/user_class_extensions.rb +10 -9
- data/config/locales/en.yml +1 -0
- data/db/default/spree/countries.rb +18 -231
- data/db/default/spree/states.rb +16 -76
- data/db/development.sqlite +0 -0
- data/db/migrate/20130213191427_create_default_stock.rb +4 -1
- data/db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb +3 -5
- data/db/migrate/20140717185932_add_default_to_spree_stock_locations.rb +3 -1
- data/db/migrate/20141012083513_create_spree_taxons_prototypes.rb +8 -0
- data/db/migrate/20141021194502_add_state_lock_version_to_order.rb +5 -0
- data/db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb +13 -0
- data/db/migrate/20141101231208_fix_adjustment_order_presence.rb +13 -0
- data/db/migrate/20141105213646_update_classifications_positions.rb +9 -0
- data/lib/generators/spree/install/install_generator.rb +3 -7
- data/lib/spree/core/controller_helpers/order.rb +5 -6
- data/lib/spree/core/importer/order.rb +16 -3
- data/lib/spree/core/search/base.rb +1 -1
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/migrations.rb +7 -3
- data/lib/spree/permitted_attributes.rb +3 -1
- data/lib/spree/testing_support/ability_helpers.rb +25 -25
- data/lib/spree/testing_support/capybara_ext.rb +2 -2
- data/lib/spree/testing_support/factories/customer_return_factory.rb +1 -1
- data/lib/spree/testing_support/factories/line_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +2 -2
- data/lib/spree/testing_support/factories/product_factory.rb +6 -0
- data/lib/spree/testing_support/factories/promotion_factory.rb +3 -3
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_factory.rb +3 -3
- data/lib/spree/testing_support/flash.rb +2 -2
- metadata +30 -17
- data/vendor/assets/javascripts/jquery.validate/localization/messages_et.js +0 -23
- data/vendor/assets/javascripts/jquery.validate/localization/messages_eu.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_hr.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ka.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_ko.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_my.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_pt_BR.js +0 -26
- data/vendor/assets/javascripts/jquery.validate/localization/messages_pt_PT.js +0 -26
- data/vendor/assets/javascripts/jquery.validate/localization/messages_sl.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_sv.js +0 -23
- data/vendor/assets/javascripts/jquery.validate/localization/messages_uk.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_zh.js +0 -25
- data/vendor/assets/javascripts/jquery.validate/localization/messages_zh_TW.js +0 -26
data/app/models/spree/variant.rb
CHANGED
@@ -9,7 +9,7 @@ module Spree
|
|
9
9
|
:shipping_category_id, :meta_description, :meta_keywords,
|
10
10
|
:shipping_category
|
11
11
|
|
12
|
-
has_many :inventory_units
|
12
|
+
has_many :inventory_units, inverse_of: :variant
|
13
13
|
has_many :line_items, inverse_of: :variant
|
14
14
|
has_many :orders, through: :line_items
|
15
15
|
|
@@ -22,9 +22,8 @@ module Spree
|
|
22
22
|
|
23
23
|
has_one :default_price,
|
24
24
|
-> { where currency: Spree::Config[:currency] },
|
25
|
-
class_name: 'Spree::Price',
|
26
|
-
|
27
|
-
|
25
|
+
class_name: 'Spree::Price', inverse_of: :variant
|
26
|
+
|
28
27
|
delegate_belongs_to :default_price, :display_price, :display_amount, :price, :price=, :currency
|
29
28
|
|
30
29
|
has_many :prices,
|
@@ -33,8 +32,9 @@ module Spree
|
|
33
32
|
inverse_of: :variant
|
34
33
|
|
35
34
|
validate :check_price
|
35
|
+
|
36
36
|
validates :cost_price, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
|
37
|
-
validates :price,
|
37
|
+
validates :price, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
|
38
38
|
validates_uniqueness_of :sku, allow_blank: true, conditions: -> { where(deleted_at: nil) }
|
39
39
|
|
40
40
|
before_validation :set_cost_currency
|
data/app/models/spree/zone.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Spree
|
2
2
|
class Zone < Spree::Base
|
3
|
-
has_many :zone_members, dependent: :destroy, class_name: "Spree::ZoneMember"
|
4
|
-
has_many :tax_rates, dependent: :destroy
|
3
|
+
has_many :zone_members, dependent: :destroy, class_name: "Spree::ZoneMember", inverse_of: :zone
|
4
|
+
has_many :tax_rates, dependent: :destroy, inverse_of: :zone
|
5
5
|
has_and_belongs_to_many :shipping_methods, :join_table => 'spree_shipping_methods_zones'
|
6
6
|
|
7
|
-
validates :name, presence: true, uniqueness: true
|
7
|
+
validates :name, presence: true, uniqueness: { allow_blank: true }
|
8
8
|
after_save :remove_defunct_members
|
9
9
|
after_save :remove_previous_default
|
10
10
|
|
@@ -92,23 +92,11 @@ module Spree
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def country_ids=(ids)
|
95
|
-
|
96
|
-
ids.reject{ |id| id.blank? }.map do |id|
|
97
|
-
member = ZoneMember.new
|
98
|
-
member.zoneable_type = 'Spree::Country'
|
99
|
-
member.zoneable_id = id
|
100
|
-
members << member
|
101
|
-
end
|
95
|
+
set_zone_members(ids, 'Spree::Country')
|
102
96
|
end
|
103
97
|
|
104
98
|
def state_ids=(ids)
|
105
|
-
|
106
|
-
ids.reject{ |id| id.blank? }.map do |id|
|
107
|
-
member = ZoneMember.new
|
108
|
-
member.zoneable_type = 'Spree::State'
|
109
|
-
member.zoneable_id = id
|
110
|
-
members << member
|
111
|
-
end
|
99
|
+
set_zone_members(ids, 'Spree::State')
|
112
100
|
end
|
113
101
|
|
114
102
|
# Indicates whether the specified zone falls entirely within the zone performing
|
@@ -136,5 +124,15 @@ module Spree
|
|
136
124
|
def remove_previous_default
|
137
125
|
Spree::Zone.where('id != ?', self.id).update_all(default_tax: false) if default_tax
|
138
126
|
end
|
127
|
+
|
128
|
+
def set_zone_members(ids, type)
|
129
|
+
zone_members.destroy_all
|
130
|
+
ids.reject{ |id| id.blank? }.map do |id|
|
131
|
+
member = ZoneMember.new
|
132
|
+
member.zoneable_type = type
|
133
|
+
member.zoneable_id = id
|
134
|
+
members << member
|
135
|
+
end
|
136
|
+
end
|
139
137
|
end
|
140
138
|
end
|
@@ -2,25 +2,26 @@ Spree::Core::Engine.config.to_prepare do
|
|
2
2
|
if Spree.user_class
|
3
3
|
Spree.user_class.class_eval do
|
4
4
|
|
5
|
-
include Spree::UserReporting
|
6
5
|
include Spree::UserApiAuthentication
|
6
|
+
include Spree::UserReporting
|
7
|
+
|
7
8
|
has_and_belongs_to_many :spree_roles,
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
9
|
+
join_table: 'spree_roles_users',
|
10
|
+
foreign_key: "user_id",
|
11
|
+
class_name: "Spree::Role"
|
11
12
|
|
12
|
-
has_many :spree_orders, :
|
13
|
+
has_many :spree_orders, foreign_key: "user_id", class_name: "Spree::Order"
|
13
14
|
|
14
|
-
belongs_to :ship_address, :
|
15
|
-
belongs_to :bill_address, :
|
15
|
+
belongs_to :ship_address, class_name: 'Spree::Address'
|
16
|
+
belongs_to :bill_address, class_name: 'Spree::Address'
|
16
17
|
|
17
18
|
# has_spree_role? simply needs to return true or false whether a user has a role or not.
|
18
19
|
def has_spree_role?(role_in_question)
|
19
|
-
spree_roles.where(:
|
20
|
+
spree_roles.where(name: role_in_question.to_s).any?
|
20
21
|
end
|
21
22
|
|
22
23
|
def last_incomplete_spree_order
|
23
|
-
spree_orders.incomplete.where(:
|
24
|
+
spree_orders.incomplete.where(user_id: self.id).order('created_at DESC').first
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
data/config/locales/en.yml
CHANGED
@@ -920,6 +920,7 @@ en:
|
|
920
920
|
or_over_price: ! '%{price} or over'
|
921
921
|
order: Order
|
922
922
|
order_adjustments: Order adjustments
|
923
|
+
order_already_updated: The order has already been updated.
|
923
924
|
order_approved: Order approved
|
924
925
|
order_canceled: Order canceled
|
925
926
|
order_details: Order Details
|
@@ -1,232 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
{ name: "Iraq", iso3: "IRQ", iso: "IQ", iso_name: "IRAQ", numcode: "368", states_required: true },
|
20
|
-
{ name: "San Marino", iso3: "SMR", iso: "SM", iso_name: "SAN MARINO", numcode: "674" },
|
21
|
-
{ name: "Ireland", iso3: "IRL", iso: "IE", iso_name: "IRELAND", numcode: "372" },
|
22
|
-
{ name: "Sao Tome and Principe", iso3: "STP", iso: "ST", iso_name: "SAO TOME AND PRINCIPE", numcode: "678" },
|
23
|
-
{ name: "Israel", iso3: "ISR", iso: "IL", iso_name: "ISRAEL", numcode: "376" },
|
24
|
-
{ name: "Saudi Arabia", iso3: "SAU", iso: "SA", iso_name: "SAUDI ARABIA", numcode: "682" },
|
25
|
-
{ name: "Italy", iso3: "ITA", iso: "IT", iso_name: "ITALY", numcode: "380" },
|
26
|
-
{ name: "Senegal", iso3: "SEN", iso: "SN", iso_name: "SENEGAL", numcode: "686" },
|
27
|
-
{ name: "Jamaica", iso3: "JAM", iso: "JM", iso_name: "JAMAICA", numcode: "388" },
|
28
|
-
{ name: "Japan", iso3: "JPN", iso: "JP", iso_name: "JAPAN", numcode: "392" },
|
29
|
-
{ name: "Jordan", iso3: "JOR", iso: "JO", iso_name: "JORDAN", numcode: "400" },
|
30
|
-
{ name: "Belgium", iso3: "BEL", iso: "BE", iso_name: "BELGIUM", numcode: "56" },
|
31
|
-
{ name: "Belize", iso3: "BLZ", iso: "BZ", iso_name: "BELIZE", numcode: "84" },
|
32
|
-
{ name: "Kazakhstan", iso3: "KAZ", iso: "KZ", iso_name: "KAZAKHSTAN", numcode: "398" },
|
33
|
-
{ name: "Uganda", iso3: "UGA", iso: "UG", iso_name: "UGANDA", numcode: "800" },
|
34
|
-
{ name: "Benin", iso3: "BEN", iso: "BJ", iso_name: "BENIN", numcode: "204" },
|
35
|
-
{ name: "Kenya", iso3: "KEN", iso: "KE", iso_name: "KENYA", numcode: "404" },
|
36
|
-
{ name: "Ukraine", iso3: "UKR", iso: "UA", iso_name: "UKRAINE", numcode: "804" },
|
37
|
-
{ name: "Bermuda", iso3: "BMU", iso: "BM", iso_name: "BERMUDA", numcode: "60" },
|
38
|
-
{ name: "Kiribati", iso3: "KIR", iso: "KI", iso_name: "KIRIBATI", numcode: "296" },
|
39
|
-
{ name: "Mexico", iso3: "MEX", iso: "MX", iso_name: "MEXICO", numcode: "484", states_required: true },
|
40
|
-
{ name: "United Arab Emirates", iso3: "ARE", iso: "AE", iso_name: "UNITED ARAB EMIRATES", numcode: "784", states_required: true },
|
41
|
-
{ name: "Bhutan", iso3: "BTN", iso: "BT", iso_name: "BHUTAN", numcode: "64" },
|
42
|
-
{ name: "Cuba", iso3: "CUB", iso: "CU", iso_name: "CUBA", numcode: "192" },
|
43
|
-
{ name: "North Korea", iso3: "PRK", iso: "KP", iso_name: "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF", numcode: "408" },
|
44
|
-
{ name: "Micronesia, Federated States of", iso3: "FSM", iso: "FM", iso_name: "MICRONESIA, FEDERATED STATES OF", numcode: "583", states_required: true },
|
45
|
-
{ name: "United Kingdom", iso3: "GBR", iso: "GB", iso_name: "UNITED KINGDOM", numcode: "826" },
|
46
|
-
{ name: "Bolivia", iso3: "BOL", iso: "BO", iso_name: "BOLIVIA", numcode: "68" },
|
47
|
-
{ name: "Cyprus", iso3: "CYP", iso: "CY", iso_name: "CYPRUS", numcode: "196" },
|
48
|
-
{ name: "South Korea", iso3: "KOR", iso: "KR", iso_name: "KOREA, REPUBLIC OF", numcode: "410" },
|
49
|
-
{ name: "Moldova, Republic of", iso3: "MDA", iso: "MD", iso_name: "MOLDOVA, REPUBLIC OF", numcode: "498" },
|
50
|
-
{ name: "United States", iso3: "USA", iso: "US", iso_name: "UNITED STATES", numcode: "840", states_required: true },
|
51
|
-
{ name: "Bosnia and Herzegovina", iso3: "BIH", iso: "BA", iso_name: "BOSNIA AND HERZEGOVINA", numcode: "70" },
|
52
|
-
{ name: "Czech Republic", iso3: "CZE", iso: "CZ", iso_name: "CZECH REPUBLIC", numcode: "203" },
|
53
|
-
{ name: "Kuwait", iso3: "KWT", iso: "KW", iso_name: "KUWAIT", numcode: "414" },
|
54
|
-
{ name: "Monaco", iso3: "MCO", iso: "MC", iso_name: "MONACO", numcode: "492" },
|
55
|
-
{ name: "Uruguay", iso3: "URY", iso: "UY", iso_name: "URUGUAY", numcode: "858" },
|
56
|
-
{ name: "Botswana", iso3: "BWA", iso: "BW", iso_name: "BOTSWANA", numcode: "72" },
|
57
|
-
{ name: "Denmark", iso3: "DNK", iso: "DK", iso_name: "DENMARK", numcode: "208" },
|
58
|
-
{ name: "Guadeloupe", iso3: "GLP", iso: "GP", iso_name: "GUADELOUPE", numcode: "312" },
|
59
|
-
{ name: "Kyrgyzstan", iso3: "KGZ", iso: "KG", iso_name: "KYRGYZSTAN", numcode: "417" },
|
60
|
-
{ name: "Mongolia", iso3: "MNG", iso: "MN", iso_name: "MONGOLIA", numcode: "496" },
|
61
|
-
{ name: "Philippines", iso3: "PHL", iso: "PH", iso_name: "PHILIPPINES", numcode: "608" },
|
62
|
-
{ name: "Brazil", iso3: "BRA", iso: "BR", iso_name: "BRAZIL", numcode: "76", states_required: true },
|
63
|
-
{ name: "Djibouti", iso3: "DJI", iso: "DJ", iso_name: "DJIBOUTI", numcode: "262" },
|
64
|
-
{ name: "Guam", iso3: "GUM", iso: "GU", iso_name: "GUAM", numcode: "316" },
|
65
|
-
{ name: "Lao People's Democratic Republic", iso3: "LAO", iso: "LA", iso_name: "LAO PEOPLE'S DEMOCRATIC REPUBLIC", numcode: "418" },
|
66
|
-
{ name: "Montserrat", iso3: "MSR", iso: "MS", iso_name: "MONTSERRAT", numcode: "500" },
|
67
|
-
{ name: "Pitcairn", iso3: "PCN", iso: "PN", iso_name: "PITCAIRN", numcode: "612" },
|
68
|
-
{ name: "Uzbekistan", iso3: "UZB", iso: "UZ", iso_name: "UZBEKISTAN", numcode: "860" },
|
69
|
-
{ name: "Brunei Darussalam", iso3: "BRN", iso: "BN", iso_name: "BRUNEI DARUSSALAM", numcode: "96" },
|
70
|
-
{ name: "Dominica", iso3: "DMA", iso: "DM", iso_name: "DOMINICA", numcode: "212" },
|
71
|
-
{ name: "Guatemala", iso3: "GTM", iso: "GT", iso_name: "GUATEMALA", numcode: "320" },
|
72
|
-
{ name: "Morocco", iso3: "MAR", iso: "MA", iso_name: "MOROCCO", numcode: "504" },
|
73
|
-
{ name: "Poland", iso3: "POL", iso: "PL", iso_name: "POLAND", numcode: "616" },
|
74
|
-
{ name: "Vanuatu", iso3: "VUT", iso: "VU", iso_name: "VANUATU", numcode: "548" },
|
75
|
-
{ name: "Dominican Republic", iso3: "DOM", iso: "DO", iso_name: "DOMINICAN REPUBLIC", numcode: "214" },
|
76
|
-
{ name: "Mozambique", iso3: "MOZ", iso: "MZ", iso_name: "MOZAMBIQUE", numcode: "508" },
|
77
|
-
{ name: "Portugal", iso3: "PRT", iso: "PT", iso_name: "PORTUGAL", numcode: "620" },
|
78
|
-
{ name: "Sudan", iso3: "SDN", iso: "SD", iso_name: "SUDAN", numcode: "736", states_required: true },
|
79
|
-
{ name: "Venezuela", iso3: "VEN", iso: "VE", iso_name: "VENEZUELA", numcode: "862", states_required: true },
|
80
|
-
{ name: "Ecuador", iso3: "ECU", iso: "EC", iso_name: "ECUADOR", numcode: "218" },
|
81
|
-
{ name: "Guinea", iso3: "GIN", iso: "GN", iso_name: "GUINEA", numcode: "324" },
|
82
|
-
{ name: "Myanmar", iso3: "MMR", iso: "MM", iso_name: "MYANMAR", numcode: "104" },
|
83
|
-
{ name: "Puerto Rico", iso3: "PRI", iso: "PR", iso_name: "PUERTO RICO", numcode: "630" },
|
84
|
-
{ name: "Suriname", iso3: "SUR", iso: "SR", iso_name: "SURINAME", numcode: "740" },
|
85
|
-
{ name: "Viet Nam", iso3: "VNM", iso: "VN", iso_name: "VIET NAM", numcode: "704" },
|
86
|
-
{ name: "Egypt", iso3: "EGY", iso: "EG", iso_name: "EGYPT", numcode: "818" },
|
87
|
-
{ name: "Guinea-Bissau", iso3: "GNB", iso: "GW", iso_name: "GUINEA-BISSAU", numcode: "624" },
|
88
|
-
{ name: "Namibia", iso3: "NAM", iso: "NA", iso_name: "NAMIBIA", numcode: "516" },
|
89
|
-
{ name: "Qatar", iso3: "QAT", iso: "QA", iso_name: "QATAR", numcode: "634" },
|
90
|
-
{ name: "Svalbard and Jan Mayen", iso3: "SJM", iso: "SJ", iso_name: "SVALBARD AND JAN MAYEN", numcode: "744" },
|
91
|
-
{ name: "El Salvador", iso3: "SLV", iso: "SV", iso_name: "EL SALVADOR", numcode: "222" },
|
92
|
-
{ name: "Guyana", iso3: "GUY", iso: "GY", iso_name: "GUYANA", numcode: "328" },
|
93
|
-
{ name: "Reunion", iso3: "REU", iso: "RE", iso_name: "REUNION", numcode: "638" },
|
94
|
-
{ name: "Haiti", iso3: "HTI", iso: "HT", iso_name: "HAITI", numcode: "332" },
|
95
|
-
{ name: "Romania", iso3: "ROU", iso: "RO", iso_name: "ROMANIA", numcode: "642" },
|
96
|
-
{ name: "Swaziland", iso3: "SWZ", iso: "SZ", iso_name: "SWAZILAND", numcode: "748" },
|
97
|
-
{ name: "Holy See (Vatican City State)", iso3: "VAT", iso: "VA", iso_name: "HOLY SEE (VATICAN CITY STATE)", numcode: "336" },
|
98
|
-
{ name: "Russian Federation", iso3: "RUS", iso: "RU", iso_name: "RUSSIAN FEDERATION", numcode: "643", states_required: true },
|
99
|
-
{ name: "Sweden", iso3: "SWE", iso: "SE", iso_name: "SWEDEN", numcode: "752" },
|
100
|
-
{ name: "Honduras", iso3: "HND", iso: "HN", iso_name: "HONDURAS", numcode: "340" },
|
101
|
-
{ name: "Rwanda", iso3: "RWA", iso: "RW", iso_name: "RWANDA", numcode: "646" },
|
102
|
-
{ name: "Switzerland", iso3: "CHE", iso: "CH", iso_name: "SWITZERLAND", numcode: "756" },
|
103
|
-
{ name: "Hong Kong", iso3: "HKG", iso: "HK", iso_name: "HONG KONG", numcode: "344" },
|
104
|
-
{ name: "Syrian Arab Republic", iso3: "SYR", iso: "SY", iso_name: "SYRIAN ARAB REPUBLIC", numcode: "760" },
|
105
|
-
{ name: "Taiwan", iso3: "TWN", iso: "TW", iso_name: "TAIWAN, PROVINCE OF CHINA", numcode: "158" },
|
106
|
-
{ name: "Tajikistan", iso3: "TJK", iso: "TJ", iso_name: "TAJIKISTAN", numcode: "762" },
|
107
|
-
{ name: "Tanzania, United Republic of", iso3: "TZA", iso: "TZ", iso_name: "TANZANIA, UNITED REPUBLIC OF", numcode: "834" },
|
108
|
-
{ name: "Armenia", iso3: "ARM", iso: "AM", iso_name: "ARMENIA", numcode: "51" },
|
109
|
-
{ name: "Aruba", iso3: "ABW", iso: "AW", iso_name: "ARUBA", numcode: "533" },
|
110
|
-
{ name: "Australia", iso3: "AUS", iso: "AU", iso_name: "AUSTRALIA", numcode: "36", states_required: true },
|
111
|
-
{ name: "Thailand", iso3: "THA", iso: "TH", iso_name: "THAILAND", numcode: "764" },
|
112
|
-
{ name: "Austria", iso3: "AUT", iso: "AT", iso_name: "AUSTRIA", numcode: "40" },
|
113
|
-
{ name: "Madagascar", iso3: "MDG", iso: "MG", iso_name: "MADAGASCAR", numcode: "450" },
|
114
|
-
{ name: "Togo", iso3: "TGO", iso: "TG", iso_name: "TOGO", numcode: "768" },
|
115
|
-
{ name: "Azerbaijan", iso3: "AZE", iso: "AZ", iso_name: "AZERBAIJAN", numcode: "31" },
|
116
|
-
{ name: "Chile", iso3: "CHL", iso: "CL", iso_name: "CHILE", numcode: "152" },
|
117
|
-
{ name: "Malawi", iso3: "MWI", iso: "MW", iso_name: "MALAWI", numcode: "454" },
|
118
|
-
{ name: "Tokelau", iso3: "TKL", iso: "TK", iso_name: "TOKELAU", numcode: "772" },
|
119
|
-
{ name: "Bahamas", iso3: "BHS", iso: "BS", iso_name: "BAHAMAS", numcode: "44" },
|
120
|
-
{ name: "China", iso3: "CHN", iso: "CN", iso_name: "CHINA", numcode: "156" },
|
121
|
-
{ name: "Malaysia", iso3: "MYS", iso: "MY", iso_name: "MALAYSIA", numcode: "458" },
|
122
|
-
{ name: "Tonga", iso3: "TON", iso: "TO", iso_name: "TONGA", numcode: "776" },
|
123
|
-
{ name: "Bahrain", iso3: "BHR", iso: "BH", iso_name: "BAHRAIN", numcode: "48" },
|
124
|
-
{ name: "Colombia", iso3: "COL", iso: "CO", iso_name: "COLOMBIA", numcode: "170" },
|
125
|
-
{ name: "Maldives", iso3: "MDV", iso: "MV", iso_name: "MALDIVES", numcode: "462" },
|
126
|
-
{ name: "Trinidad and Tobago", iso3: "TTO", iso: "TT", iso_name: "TRINIDAD AND TOBAGO", numcode: "780" },
|
127
|
-
{ name: "Bangladesh", iso3: "BGD", iso: "BD", iso_name: "BANGLADESH", numcode: "50" },
|
128
|
-
{ name: "Comoros", iso3: "COM", iso: "KM", iso_name: "COMOROS", numcode: "174", states_required: true },
|
129
|
-
{ name: "French Polynesia", iso3: "PYF", iso: "PF", iso_name: "FRENCH POLYNESIA", numcode: "258" },
|
130
|
-
{ name: "Mali", iso3: "MLI", iso: "ML", iso_name: "MALI", numcode: "466" },
|
131
|
-
{ name: "Norfolk Island", iso3: "NFK", iso: "NF", iso_name: "NORFOLK ISLAND", numcode: "574" },
|
132
|
-
{ name: "Tunisia", iso3: "TUN", iso: "TN", iso_name: "TUNISIA", numcode: "788" },
|
133
|
-
{ name: "Barbados", iso3: "BRB", iso: "BB", iso_name: "BARBADOS", numcode: "52" },
|
134
|
-
{ name: "Congo", iso3: "COG", iso: "CG", iso_name: "CONGO", numcode: "178" },
|
135
|
-
{ name: "Gabon", iso3: "GAB", iso: "GA", iso_name: "GABON", numcode: "266" },
|
136
|
-
{ name: "Malta", iso3: "MLT", iso: "MT", iso_name: "MALTA", numcode: "470" },
|
137
|
-
{ name: "Northern Mariana Islands", iso3: "MNP", iso: "MP", iso_name: "NORTHERN MARIANA ISLANDS", numcode: "580" },
|
138
|
-
{ name: "Turkey", iso3: "TUR", iso: "TR", iso_name: "TURKEY", numcode: "792" },
|
139
|
-
{ name: "Congo, the Democratic Republic of the", iso3: "COD", iso: "CD", iso_name: "CONGO, THE DEMOCRATIC REPUBLIC OF THE", numcode: "180" },
|
140
|
-
{ name: "Marshall Islands", iso3: "MHL", iso: "MH", iso_name: "MARSHALL ISLANDS", numcode: "584" },
|
141
|
-
{ name: "Norway", iso3: "NOR", iso: "NO", iso_name: "NORWAY", numcode: "578" },
|
142
|
-
{ name: "Turkmenistan", iso3: "TKM", iso: "TM", iso_name: "TURKMENISTAN", numcode: "795" },
|
143
|
-
{ name: "Belarus", iso3: "BLR", iso: "BY", iso_name: "BELARUS", numcode: "112" },
|
144
|
-
{ name: "Cook Islands", iso3: "COK", iso: "CK", iso_name: "COOK ISLANDS", numcode: "184" },
|
145
|
-
{ name: "Gambia", iso3: "GMB", iso: "GM", iso_name: "GAMBIA", numcode: "270" },
|
146
|
-
{ name: "Martinique", iso3: "MTQ", iso: "MQ", iso_name: "MARTINIQUE", numcode: "474" },
|
147
|
-
{ name: "Oman", iso3: "OMN", iso: "OM", iso_name: "OMAN", numcode: "512" },
|
148
|
-
{ name: "Seychelles", iso3: "SYC", iso: "SC", iso_name: "SEYCHELLES", numcode: "690" },
|
149
|
-
{ name: "Turks and Caicos Islands", iso3: "TCA", iso: "TC", iso_name: "TURKS AND CAICOS ISLANDS", numcode: "796" },
|
150
|
-
{ name: "Georgia", iso3: "GEO", iso: "GE", iso_name: "GEORGIA", numcode: "268" },
|
151
|
-
{ name: "Mauritania", iso3: "MRT", iso: "MR", iso_name: "MAURITANIA", numcode: "478" },
|
152
|
-
{ name: "Pakistan", iso3: "PAK", iso: "PK", iso_name: "PAKISTAN", numcode: "586", states_required: true },
|
153
|
-
{ name: "Sierra Leone", iso3: "SLE", iso: "SL", iso_name: "SIERRA LEONE", numcode: "694" },
|
154
|
-
{ name: "Tuvalu", iso3: "TUV", iso: "TV", iso_name: "TUVALU", numcode: "798" },
|
155
|
-
{ name: "Costa Rica", iso3: "CRI", iso: "CR", iso_name: "COSTA RICA", numcode: "188" },
|
156
|
-
{ name: "Germany", iso3: "DEU", iso: "DE", iso_name: "GERMANY", numcode: "276" },
|
157
|
-
{ name: "Mauritius", iso3: "MUS", iso: "MU", iso_name: "MAURITIUS", numcode: "480" },
|
158
|
-
{ name: "Palau", iso3: "PLW", iso: "PW", iso_name: "PALAU", numcode: "585" },
|
159
|
-
{ name: "Cote D'Ivoire", iso3: "CIV", iso: "CI", iso_name: "COTE D'IVOIRE", numcode: "384" },
|
160
|
-
{ name: "Panama", iso3: "PAN", iso: "PA", iso_name: "PANAMA", numcode: "591" },
|
161
|
-
{ name: "Singapore", iso3: "SGP", iso: "SG", iso_name: "SINGAPORE", numcode: "702" },
|
162
|
-
{ name: "Croatia", iso3: "HRV", iso: "HR", iso_name: "CROATIA", numcode: "191" },
|
163
|
-
{ name: "Ghana", iso3: "GHA", iso: "GH", iso_name: "GHANA", numcode: "288" },
|
164
|
-
{ name: "Papua New Guinea", iso3: "PNG", iso: "PG", iso_name: "PAPUA NEW GUINEA", numcode: "598" },
|
165
|
-
{ name: "Slovakia", iso3: "SVK", iso: "SK", iso_name: "SLOVAKIA", numcode: "703" },
|
166
|
-
{ name: "Gibraltar", iso3: "GIB", iso: "GI", iso_name: "GIBRALTAR", numcode: "292" },
|
167
|
-
{ name: "Paraguay", iso3: "PRY", iso: "PY", iso_name: "PARAGUAY", numcode: "600" },
|
168
|
-
{ name: "Slovenia", iso3: "SVN", iso: "SI", iso_name: "SLOVENIA", numcode: "705" },
|
169
|
-
{ name: "Greece", iso3: "GRC", iso: "GR", iso_name: "GREECE", numcode: "300" },
|
170
|
-
{ name: "Peru", iso3: "PER", iso: "PE", iso_name: "PERU", numcode: "604" },
|
171
|
-
{ name: "Solomon Islands", iso3: "SLB", iso: "SB", iso_name: "SOLOMON ISLANDS", numcode: "90" },
|
172
|
-
{ name: "Greenland", iso3: "GRL", iso: "GL", iso_name: "GREENLAND", numcode: "304" },
|
173
|
-
{ name: "Somalia", iso3: "SOM", iso: "SO", iso_name: "SOMALIA", numcode: "706", states_required: true },
|
174
|
-
{ name: "Grenada", iso3: "GRD", iso: "GD", iso_name: "GRENADA", numcode: "308" },
|
175
|
-
{ name: "South Africa", iso3: "ZAF", iso: "ZA", iso_name: "SOUTH AFRICA", numcode: "710" },
|
176
|
-
{ name: "Spain", iso3: "ESP", iso: "ES", iso_name: "SPAIN", numcode: "724" },
|
177
|
-
{ name: "Sri Lanka", iso3: "LKA", iso: "LK", iso_name: "SRI LANKA", numcode: "144" },
|
178
|
-
{ name: "Afghanistan", iso3: "AFG", iso: "AF", iso_name: "AFGHANISTAN", numcode: "4" },
|
179
|
-
{ name: "Albania", iso3: "ALB", iso: "AL", iso_name: "ALBANIA", numcode: "8" },
|
180
|
-
{ name: "Algeria", iso3: "DZA", iso: "DZ", iso_name: "ALGERIA", numcode: "12" },
|
181
|
-
{ name: "Latvia", iso3: "LVA", iso: "LV", iso_name: "LATVIA", numcode: "428" },
|
182
|
-
{ name: "American Samoa", iso3: "ASM", iso: "AS", iso_name: "AMERICAN SAMOA", numcode: "16" },
|
183
|
-
{ name: "Bulgaria", iso3: "BGR", iso: "BG", iso_name: "BULGARIA", numcode: "100" },
|
184
|
-
{ name: "Lebanon", iso3: "LBN", iso: "LB", iso_name: "LEBANON", numcode: "422" },
|
185
|
-
{ name: "Andorra", iso3: "AND", iso: "AD", iso_name: "ANDORRA", numcode: "20" },
|
186
|
-
{ name: "Burkina Faso", iso3: "BFA", iso: "BF", iso_name: "BURKINA FASO", numcode: "854" },
|
187
|
-
{ name: "Lesotho", iso3: "LSO", iso: "LS", iso_name: "LESOTHO", numcode: "426" },
|
188
|
-
{ name: "Angola", iso3: "AGO", iso: "AO", iso_name: "ANGOLA", numcode: "24" },
|
189
|
-
{ name: "Burundi", iso3: "BDI", iso: "BI", iso_name: "BURUNDI", numcode: "108" },
|
190
|
-
{ name: "Liberia", iso3: "LBR", iso: "LR", iso_name: "LIBERIA", numcode: "430" },
|
191
|
-
{ name: "Virgin Islands, British", iso3: "VGB", iso: "VG", iso_name: "VIRGIN ISLANDS, BRITISH", numcode: "92" },
|
192
|
-
{ name: "Anguilla", iso3: "AIA", iso: "AI", iso_name: "ANGUILLA", numcode: "660" },
|
193
|
-
{ name: "Cambodia", iso3: "KHM", iso: "KH", iso_name: "CAMBODIA", numcode: "116" },
|
194
|
-
{ name: "Equatorial Guinea", iso3: "GNQ", iso: "GQ", iso_name: "EQUATORIAL GUINEA", numcode: "226" },
|
195
|
-
{ name: "Libyan Arab Jamahiriya", iso3: "LBY", iso: "LY", iso_name: "LIBYAN ARAB JAMAHIRIYA", numcode: "434" },
|
196
|
-
{ name: "Nauru", iso3: "NRU", iso: "NR", iso_name: "NAURU", numcode: "520" },
|
197
|
-
{ name: "Virgin Islands, U.S.", iso3: "VIR", iso: "VI", iso_name: "VIRGIN ISLANDS, U.S.", numcode: "850" },
|
198
|
-
{ name: "Antigua and Barbuda", iso3: "ATG", iso: "AG", iso_name: "ANTIGUA AND BARBUDA", numcode: "28" },
|
199
|
-
{ name: "Cameroon", iso3: "CMR", iso: "CM", iso_name: "CAMEROON", numcode: "120" },
|
200
|
-
{ name: "Liechtenstein", iso3: "LIE", iso: "LI", iso_name: "LIECHTENSTEIN", numcode: "438" },
|
201
|
-
{ name: "Nepal", iso3: "NPL", iso: "NP", iso_name: "NEPAL", numcode: "524", states_required: true },
|
202
|
-
{ name: "Wallis and Futuna", iso3: "WLF", iso: "WF", iso_name: "WALLIS AND FUTUNA", numcode: "876" },
|
203
|
-
{ name: "Western Sahara", iso3: "ESH", iso: "EH", iso_name: "WESTERN SAHARA", numcode: "732" },
|
204
|
-
{ name: "Argentina", iso3: "ARG", iso: "AR", iso_name: "ARGENTINA", numcode: "32" },
|
205
|
-
{ name: "Canada", iso3: "CAN", iso: "CA", iso_name: "CANADA", numcode: "124", states_required: true },
|
206
|
-
{ name: "Eritrea", iso3: "ERI", iso: "ER", iso_name: "ERITREA", numcode: "232" },
|
207
|
-
{ name: "Lithuania", iso3: "LTU", iso: "LT", iso_name: "LITHUANIA", numcode: "440" },
|
208
|
-
{ name: "Netherlands", iso3: "NLD", iso: "NL", iso_name: "NETHERLANDS", numcode: "528" },
|
209
|
-
{ name: "Yemen", iso3: "YEM", iso: "YE", iso_name: "YEMEN", numcode: "887" },
|
210
|
-
{ name: "Cape Verde", iso3: "CPV", iso: "CV", iso_name: "CAPE VERDE", numcode: "132" },
|
211
|
-
{ name: "Estonia", iso3: "EST", iso: "EE", iso_name: "ESTONIA", numcode: "233" },
|
212
|
-
{ name: "Luxembourg", iso3: "LUX", iso: "LU", iso_name: "LUXEMBOURG", numcode: "442" },
|
213
|
-
{ name: "Netherlands Antilles", iso3: "ANT", iso: "AN", iso_name: "NETHERLANDS ANTILLES", numcode: "530" },
|
214
|
-
{ name: "Saint Helena", iso3: "SHN", iso: "SH", iso_name: "SAINT HELENA", numcode: "654" },
|
215
|
-
{ name: "Zambia", iso3: "ZMB", iso: "ZM", iso_name: "ZAMBIA", numcode: "894" },
|
216
|
-
{ name: "Cayman Islands", iso3: "CYM", iso: "KY", iso_name: "CAYMAN ISLANDS", numcode: "136" },
|
217
|
-
{ name: "Ethiopia", iso3: "ETH", iso: "ET", iso_name: "ETHIOPIA", numcode: "231", states_required: true },
|
218
|
-
{ name: "Hungary", iso3: "HUN", iso: "HU", iso_name: "HUNGARY", numcode: "348" },
|
219
|
-
{ name: "Macao", iso3: "MAC", iso: "MO", iso_name: "MACAO", numcode: "446" },
|
220
|
-
{ name: "New Caledonia", iso3: "NCL", iso: "NC", iso_name: "NEW CALEDONIA", numcode: "540" },
|
221
|
-
{ name: "Zimbabwe", iso3: "ZWE", iso: "ZW", iso_name: "ZIMBABWE", numcode: "716" },
|
222
|
-
{ name: "Central African Republic", iso3: "CAF", iso: "CF", iso_name: "CENTRAL AFRICAN REPUBLIC", numcode: "140" },
|
223
|
-
{ name: "Falkland Islands (Malvinas)", iso3: "FLK", iso: "FK", iso_name: "FALKLAND ISLANDS (MALVINAS)", numcode: "238" },
|
224
|
-
{ name: "Iceland", iso3: "ISL", iso: "IS", iso_name: "ICELAND", numcode: "352" },
|
225
|
-
{ name: "Macedonia", iso3: "MKD", iso: "MK", iso_name: "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF", numcode: "807" },
|
226
|
-
{ name: "New Zealand", iso3: "NZL", iso: "NZ", iso_name: "NEW ZEALAND", numcode: "554" },
|
227
|
-
{ name: "Saint Kitts and Nevis", iso3: "KNA", iso: "KN", iso_name: "SAINT KITTS AND NEVIS", numcode: "659", states_required: true },
|
228
|
-
{ name: "Serbia", iso3: "SRB", iso: "RS", "iso_name" => "SERBIA", numcode: "999" },
|
229
|
-
{ name: "Montenegro", iso3: "MNE", iso: "ME", iso_name: "MONTENEGRO", numcode: "499" },
|
230
|
-
{ name: "Jersey", iso3: "JEY", iso: "JE", iso_name: "JERSEY", numcode: "44" }
|
231
|
-
])
|
1
|
+
require 'carmen'
|
2
|
+
|
3
|
+
countries = []
|
4
|
+
Carmen::Country.all.each do |country|
|
5
|
+
countries << {
|
6
|
+
name: country.name,
|
7
|
+
iso3: country.alpha_3_code,
|
8
|
+
iso: country.alpha_2_code,
|
9
|
+
iso_name: country.name.upcase,
|
10
|
+
numcode: country.numeric_code,
|
11
|
+
states_required: country.subregions?
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
ActiveRecord::Base.transaction do
|
16
|
+
Spree::Country.create!(countries)
|
17
|
+
end
|
18
|
+
|
232
19
|
Spree::Config[:default_country_id] = Spree::Country.find_by(name: "United States").id
|
data/db/default/spree/states.rb
CHANGED
@@ -1,76 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
{ name: 'Idaho', abbr: 'ID', country: united_states },
|
18
|
-
{ name: 'Nebraska', abbr: 'NE', country: united_states },
|
19
|
-
{ name: 'Pennsylvania', abbr: 'PA', country: united_states },
|
20
|
-
{ name: 'Hawaii', abbr: 'HI', country: united_states },
|
21
|
-
{ name: 'Utah', abbr: 'UT', country: united_states },
|
22
|
-
{ name: 'Vermont', abbr: 'VT', country: united_states },
|
23
|
-
{ name: 'Delaware', abbr: 'DE', country: united_states },
|
24
|
-
{ name: 'Rhode Island', abbr: 'RI', country: united_states },
|
25
|
-
{ name: 'Oklahoma', abbr: 'OK', country: united_states },
|
26
|
-
{ name: 'Louisiana', abbr: 'LA', country: united_states },
|
27
|
-
{ name: 'Montana', abbr: 'MT', country: united_states },
|
28
|
-
{ name: 'Tennessee', abbr: 'TN', country: united_states },
|
29
|
-
{ name: 'Maryland', abbr: 'MD', country: united_states },
|
30
|
-
{ name: 'Florida', abbr: 'FL', country: united_states },
|
31
|
-
{ name: 'Virginia', abbr: 'VA', country: united_states },
|
32
|
-
{ name: 'Minnesota', abbr: 'MN', country: united_states },
|
33
|
-
{ name: 'New Jersey', abbr: 'NJ', country: united_states },
|
34
|
-
{ name: 'Ohio', abbr: 'OH', country: united_states },
|
35
|
-
{ name: 'California', abbr: 'CA', country: united_states },
|
36
|
-
{ name: 'North Dakota', abbr: 'ND', country: united_states },
|
37
|
-
{ name: 'Maine', abbr: 'ME', country: united_states },
|
38
|
-
{ name: 'Indiana', abbr: 'IN', country: united_states },
|
39
|
-
{ name: 'Texas', abbr: 'TX', country: united_states },
|
40
|
-
{ name: 'Oregon', abbr: 'OR', country: united_states },
|
41
|
-
{ name: 'Wyoming', abbr: 'WY', country: united_states },
|
42
|
-
{ name: 'Alabama', abbr: 'AL', country: united_states },
|
43
|
-
{ name: 'Iowa', abbr: 'IA', country: united_states },
|
44
|
-
{ name: 'Mississippi', abbr: 'MS', country: united_states },
|
45
|
-
{ name: 'Kentucky', abbr: 'KY', country: united_states },
|
46
|
-
{ name: 'New Mexico', abbr: 'NM', country: united_states },
|
47
|
-
{ name: 'Georgia', abbr: 'GA', country: united_states },
|
48
|
-
{ name: 'Colorado', abbr: 'CO', country: united_states },
|
49
|
-
{ name: 'Massachusetts', abbr: 'MA', country: united_states },
|
50
|
-
{ name: 'Connecticut', abbr: 'CT', country: united_states },
|
51
|
-
{ name: 'New York', abbr: 'NY', country: united_states },
|
52
|
-
{ name: 'South Carolina', abbr: 'SC', country: united_states },
|
53
|
-
{ name: 'Alaska', abbr: 'AK', country: united_states },
|
54
|
-
{ name: 'West Virginia', abbr: 'WV', country: united_states },
|
55
|
-
{ name: 'U.S. Armed Forces - Americas', abbr: 'AA', country: united_states },
|
56
|
-
{ name: 'U.S. Armed Forces - Europe', abbr: 'AE', country: united_states },
|
57
|
-
{ name: 'U.S. Armed Forces - Pacific', abbr: 'AP', country: united_states }
|
58
|
-
])
|
59
|
-
|
60
|
-
canada = Spree::Country.find_by(name: 'Canada')
|
61
|
-
|
62
|
-
Spree::State.create!([
|
63
|
-
{ name: "Yukon", abbr: "YT", country: canada },
|
64
|
-
{ name: "Nunavut", abbr: "NU", country: canada },
|
65
|
-
{ name: "British Columbia", abbr: "BC", country: canada },
|
66
|
-
{ name: "Alberta", abbr: "AB", country: canada },
|
67
|
-
{ name: "Saskatchewan", abbr: "SK", country: canada },
|
68
|
-
{ name: "Manitoba", abbr: "MB", country: canada },
|
69
|
-
{ name: "Ontario", abbr: "ON", country: canada },
|
70
|
-
{ name: "Quebec", abbr: "QC", country: canada },
|
71
|
-
{ name: "New Brunswick", abbr: "NB", country: canada },
|
72
|
-
{ name: "Newfoundland and Labrador", abbr: "NL", country: canada },
|
73
|
-
{ name: "Nova Scotia", abbr: "NS", country: canada },
|
74
|
-
{ name: "Prince Edward Island", abbr: "PE", country: canada },
|
75
|
-
{ name: "Northwest Territories", abbr: "NT", country: canada }
|
76
|
-
])
|
1
|
+
ActiveRecord::Base.transaction do
|
2
|
+
Spree::Country.all.each do |country|
|
3
|
+
carmen_country = Carmen::Country.named(country.name)
|
4
|
+
@states ||= []
|
5
|
+
if carmen_country.subregions?
|
6
|
+
carmen_country.subregions.each do |subregion|
|
7
|
+
@states << {
|
8
|
+
name: subregion.name,
|
9
|
+
abbr: subregion.code,
|
10
|
+
country: country
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
Spree::State.create!(@states)
|
16
|
+
end
|
File without changes
|
@@ -1,5 +1,9 @@
|
|
1
1
|
class CreateDefaultStock < ActiveRecord::Migration
|
2
2
|
def up
|
3
|
+
unless column_exists? :spree_stock_locations, :default
|
4
|
+
add_column :spree_stock_locations, :default, :boolean, null: false, default: false
|
5
|
+
end
|
6
|
+
|
3
7
|
Spree::StockLocation.skip_callback(:create, :after, :create_stock_items)
|
4
8
|
Spree::StockLocation.skip_callback(:save, :after, :ensure_one_default)
|
5
9
|
Spree::StockItem.skip_callback(:save, :after, :process_backorders)
|
@@ -28,4 +32,3 @@ class CreateDefaultStock < ActiveRecord::Migration
|
|
28
32
|
Spree::StockItem.delete_all
|
29
33
|
end
|
30
34
|
end
|
31
|
-
|
@@ -3,10 +3,8 @@ class SetShipmentTotalForUsersUpgrading < ActiveRecord::Migration
|
|
3
3
|
# NOTE You might not need this at all unless you're upgrading from Spree 2.1.x
|
4
4
|
# or below. For those upgrading this should populate the Order#shipment_total
|
5
5
|
# for legacy orders
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
WHERE spree_shipments.order_id = spree_orders.id)
|
10
|
-
WHERE spree_orders.completed_at IS NOT NULL AND spree_orders.shipment_total = 0"
|
6
|
+
Spree::Order.complete.where('shipment_total = ?', 0).includes(:shipments).find_each do |order|
|
7
|
+
order.update_column(:shipment_total, order.shipments.sum(:cost))
|
8
|
+
end
|
11
9
|
end
|
12
10
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class AddDefaultToSpreeStockLocations < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
|
3
|
+
unless column_exists? :spree_stock_locations, :default
|
4
|
+
add_column :spree_stock_locations, :default, :boolean, null: false, default: false
|
5
|
+
end
|
4
6
|
end
|
5
7
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class AddCounterCacheFromSpreeVariantsToSpreeStockItems < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column :spree_variants, :stock_items_count, :integer, default: 0, null: false
|
4
|
+
|
5
|
+
Spree::Variant.find_each do |variant|
|
6
|
+
Spree::Variant.reset_counters(variant.id, :stock_items)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
remove_column :spree_variants, :stock_items_count
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class FixAdjustmentOrderPresence < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
say 'Fixing adjustments without direct order reference'
|
4
|
+
Spree::Adjustment.where(order: nil).find_each do |adjustment|
|
5
|
+
adjustable = adjustment.adjustable
|
6
|
+
if adjustable.is_a? Spree::Order
|
7
|
+
adjustment.update_attributes!(order_id: adjustable.id)
|
8
|
+
else
|
9
|
+
adjustment.update_attributes!(adjustable: adjustable.order)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -53,14 +53,10 @@ User-agent: *
|
|
53
53
|
Disallow: /checkout
|
54
54
|
Disallow: /cart
|
55
55
|
Disallow: /orders
|
56
|
-
Disallow: /
|
57
|
-
Disallow: /line_items
|
58
|
-
Disallow: /password_resets
|
59
|
-
Disallow: /states
|
60
|
-
Disallow: /user_sessions
|
61
|
-
Disallow: /user_registrations
|
62
|
-
Disallow: /users
|
56
|
+
Disallow: /user
|
63
57
|
Disallow: /account
|
58
|
+
Disallow: /api
|
59
|
+
Disallow: /password
|
64
60
|
ROBOTS
|
65
61
|
end
|
66
62
|
|