solidus_core 1.1.0.pre1 → 1.1.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/mailers/spree/carton_mailer.rb +12 -1
- data/app/models/concerns/spree/user_address_book.rb +17 -8
- data/app/models/concerns/spree/user_methods.rb +3 -6
- data/app/models/spree/ability.rb +1 -1
- data/app/models/spree/adjustment.rb +1 -1
- data/app/models/spree/app_configuration.rb +11 -0
- data/app/models/spree/order.rb +6 -6
- data/app/models/spree/order/checkout.rb +9 -0
- data/app/models/spree/order_capturing.rb +4 -1
- data/app/models/spree/order_contents.rb +5 -0
- data/app/models/spree/order_shipping.rb +1 -1
- data/app/models/spree/payment.rb +5 -2
- data/app/models/spree/payment/processing.rb +1 -1
- data/app/models/spree/product.rb +1 -1
- data/app/models/spree/promotion.rb +8 -1
- data/app/models/spree/promotion/rules/first_repeat_purchase_since.rb +36 -0
- data/app/models/spree/promotion/rules/product.rb +2 -1
- data/app/models/spree/promotion_handler/cart.rb +1 -14
- data/app/models/spree/prototype.rb +3 -1
- data/app/models/spree/prototype_taxon.rb +6 -0
- data/app/models/spree/taxon.rb +2 -1
- data/app/models/spree/tracker.rb +1 -1
- data/app/models/spree/transfer_item.rb +2 -6
- data/config/locales/en.yml +10 -1
- data/db/default/spree/zones.rb +2 -2
- data/db/migrate/20140713140455_create_spree_return_authorization_reasons.rb +13 -11
- data/db/migrate/20150128032538_remove_environment_from_tracker.rb +6 -0
- data/db/migrate/20150515211137_fix_adjustment_order_id.rb +80 -0
- data/db/migrate/20150609093816_increase_scale_on_pre_tax_amounts.rb +16 -0
- data/db/migrate/20150826002555_convert_habtm_to_hmt_for_taxon_prototypes.rb +15 -0
- data/db/migrate/20151010003252_add_foreign_keys_for_taxons_prototypes.rb +6 -0
- data/db/migrate/20151013222921_remove_token_permissions_table.rb +16 -0
- data/db/migrate/20151014213349_rename_identifier_to_number_for_payment.rb +7 -0
- data/db/migrate/20151015203732_add_foreign_keys_for_product_promotion_rules.rb +9 -0
- data/db/migrate/20151021113730_add_sale_to_spree_promotions.rb +6 -0
- data/db/migrate/20151021163309_convert_sale_promotions.rb +28 -0
- data/lib/spree/core.rb +2 -0
- data/lib/spree/core/controller_helpers/strong_parameters.rb +7 -0
- data/lib/spree/core/engine.rb +2 -1
- data/lib/spree/deprecation.rb +3 -0
- data/lib/spree/mailer_previews/carton_preview.rb +1 -1
- data/lib/spree/permission_sets.rb +23 -0
- data/{app/models → lib}/spree/permission_sets/base.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/configuration_display.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/configuration_management.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/dashboard_display.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/default_customer.rb +2 -1
- data/{app/models → lib}/spree/permission_sets/order_display.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/order_management.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/product_display.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/product_management.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/promotion_display.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/promotion_management.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/report_display.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/restricted_stock_display.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/restricted_stock_management.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/restricted_stock_transfer_display.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/restricted_stock_transfer_management.rb +22 -12
- data/{app/models → lib}/spree/permission_sets/stock_display.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/stock_management.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/stock_transfer_display.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/stock_transfer_management.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/super_user.rb +0 -0
- data/{app/models → lib}/spree/permission_sets/user_display.rb +0 -0
- data/lib/spree/permission_sets/user_management.rb +21 -0
- data/lib/spree/permitted_attributes.rb +7 -4
- data/lib/spree/testing_support/factories/order_factory.rb +6 -2
- data/lib/spree/testing_support/factories/tracker_factory.rb +0 -1
- data/lib/spree/testing_support/order_walkthrough.rb +22 -19
- metadata +41 -27
- data/app/models/spree/permission_sets/user_management.rb +0 -12
data/db/default/spree/zones.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
eu_vat = Spree::Zone.
|
2
|
-
north_america = Spree::Zone.
|
1
|
+
eu_vat = Spree::Zone.find_or_create_by!(name: "EU_VAT", description: "Countries that make up the EU VAT zone.")
|
2
|
+
north_america = Spree::Zone.find_or_create_by!(name: "North America", description: "USA + Canada")
|
3
3
|
|
4
4
|
["Poland", "Finland", "Portugal", "Romania", "Germany", "France",
|
5
5
|
"Slovakia", "Hungary", "Slovenia", "Ireland", "Austria", "Spain",
|
@@ -1,4 +1,8 @@
|
|
1
1
|
class CreateSpreeReturnAuthorizationReasons < ActiveRecord::Migration
|
2
|
+
class ReturnAuthorizationReason < ActiveRecord::Base
|
3
|
+
self.table_name = 'spree_return_authorization_reasons'
|
4
|
+
end
|
5
|
+
|
2
6
|
def change
|
3
7
|
create_table :spree_return_authorization_reasons do |t|
|
4
8
|
t.string :name
|
@@ -10,17 +14,15 @@ class CreateSpreeReturnAuthorizationReasons < ActiveRecord::Migration
|
|
10
14
|
|
11
15
|
reversible do |direction|
|
12
16
|
direction.up do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Spree::ReturnAuthorizationReason.create!(name: 'Unauthorized purchase')
|
23
|
-
end
|
17
|
+
ReturnAuthorizationReason.create!(name: 'Better price available')
|
18
|
+
ReturnAuthorizationReason.create!(name: 'Missed estimated delivery date')
|
19
|
+
ReturnAuthorizationReason.create!(name: 'Missing parts or accessories')
|
20
|
+
ReturnAuthorizationReason.create!(name: 'Damaged/Defective')
|
21
|
+
ReturnAuthorizationReason.create!(name: 'Different from what was ordered')
|
22
|
+
ReturnAuthorizationReason.create!(name: 'Different from description')
|
23
|
+
ReturnAuthorizationReason.create!(name: 'No longer needed/wanted')
|
24
|
+
ReturnAuthorizationReason.create!(name: 'Accidental order')
|
25
|
+
ReturnAuthorizationReason.create!(name: 'Unauthorized purchase')
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -0,0 +1,80 @@
|
|
1
|
+
class FixAdjustmentOrderId < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
say 'Populate order_id from adjustable_id where appropriate'
|
4
|
+
|
5
|
+
# 3 separate execute calls to workaround MySQL limitation
|
6
|
+
execute(<<-'SQL'.squish)
|
7
|
+
UPDATE
|
8
|
+
spree_adjustments
|
9
|
+
SET
|
10
|
+
order_id = adjustable_id
|
11
|
+
WHERE
|
12
|
+
adjustable_type = 'Spree::Order'
|
13
|
+
AND order_id IS NULL
|
14
|
+
SQL
|
15
|
+
|
16
|
+
execute(<<-'SQL'.squish)
|
17
|
+
UPDATE
|
18
|
+
spree_adjustments
|
19
|
+
SET
|
20
|
+
order_id =
|
21
|
+
(SELECT order_id FROM spree_line_items WHERE spree_line_items.id = spree_adjustments.adjustable_id)
|
22
|
+
WHERE
|
23
|
+
adjustable_type = 'Spree::LineItem'
|
24
|
+
AND order_id IS NULL
|
25
|
+
;
|
26
|
+
SQL
|
27
|
+
|
28
|
+
execute(<<-'SQL'.squish)
|
29
|
+
UPDATE
|
30
|
+
spree_adjustments
|
31
|
+
SET
|
32
|
+
order_id =
|
33
|
+
(SELECT order_id FROM spree_shipments WHERE spree_shipments.id = spree_adjustments.adjustable_id)
|
34
|
+
WHERE
|
35
|
+
adjustable_type = 'Spree::Shipment'
|
36
|
+
AND order_id IS NULL
|
37
|
+
SQL
|
38
|
+
|
39
|
+
say 'Fix schema for spree_adjustments order_id column'
|
40
|
+
change_table :spree_adjustments do |t|
|
41
|
+
t.change :order_id, :integer, null: false
|
42
|
+
t.change :adjustable_id, :integer, null: false
|
43
|
+
|
44
|
+
add_foreign_key :spree_adjustments,
|
45
|
+
:spree_orders,
|
46
|
+
name: 'fk_spree_adjustments_order_id', # default is indeterministic
|
47
|
+
column: :order_id,
|
48
|
+
on_delete: :restrict, # handled by models
|
49
|
+
on_update: :restrict # handled by models
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
if connection.adapter_name.eql?('PostgreSQL')
|
54
|
+
# Negated Logical implication.
|
55
|
+
#
|
56
|
+
# When adjustable_type is 'Spree::Order' (p) the adjustable_id must be order_id (q).
|
57
|
+
#
|
58
|
+
# When adjustable_type is NOT 'Spree::Order' the adjustable id allowed to be any value (including of order_id in
|
59
|
+
# case foreign keys match). XOR does not work here.
|
60
|
+
#
|
61
|
+
# Postgresql does not have an operator for logical implication. So we need to build the following truth table
|
62
|
+
# via AND with OR:
|
63
|
+
#
|
64
|
+
# p q | CHECK = !(p -> q)
|
65
|
+
# -----------
|
66
|
+
# t t | t
|
67
|
+
# t f | f
|
68
|
+
# f t | t
|
69
|
+
# f f | t
|
70
|
+
#
|
71
|
+
# According to de-morgans law the logical implication q -> p is equivalent to !p || q
|
72
|
+
#
|
73
|
+
execute(<<-SQL.squish)
|
74
|
+
ALTER TABLE ONLY spree_adjustments
|
75
|
+
ADD CONSTRAINT check_spree_adjustments_order_id CHECK
|
76
|
+
(adjustable_type <> 'Spree::Order' OR order_id = adjustable_id);
|
77
|
+
SQL
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class IncreaseScaleOnPreTaxAmounts < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
# set pre_tax_amount on shipments to discounted_amount - included_tax_total
|
4
|
+
# so that the null: false option on the shipment pre_tax_amount doesn't generate
|
5
|
+
# errors.
|
6
|
+
#
|
7
|
+
execute(<<-SQL)
|
8
|
+
UPDATE spree_shipments
|
9
|
+
SET pre_tax_amount = (cost + promo_total) - included_tax_total
|
10
|
+
WHERE pre_tax_amount IS NULL;
|
11
|
+
SQL
|
12
|
+
|
13
|
+
change_column :spree_line_items, :pre_tax_amount, :decimal, precision: 12, scale: 4, default: 0.0, null: false
|
14
|
+
change_column :spree_shipments, :pre_tax_amount, :decimal, precision: 12, scale: 4, default: 0.0, null: false
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ConvertHabtmToHmtForTaxonPrototypes < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column :spree_taxons_prototypes, :created_at, :datetime
|
4
|
+
add_column :spree_taxons_prototypes, :updated_at, :datetime
|
5
|
+
|
6
|
+
rename_table :spree_taxons_prototypes, :spree_prototype_taxons
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
rename_table :spree_prototype_taxons, :spree_taxons_prototypes
|
11
|
+
|
12
|
+
remove_column :spree_taxons_prototypes, :created_at, :datetime
|
13
|
+
remove_column :spree_taxons_prototypes, :updated_at, :datetime
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This is named the same as the migration in spree 3.0 so it will not be copied
|
2
|
+
# if that has already been run.
|
3
|
+
class RemoveTokenPermissionsTable < ActiveRecord::Migration
|
4
|
+
def up
|
5
|
+
drop_table :spree_tokenized_permissions
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
create_table "spree_tokenized_permissions" do |t|
|
10
|
+
t.integer "permissable_id"
|
11
|
+
t.string "permissable_type"
|
12
|
+
t.string "token"
|
13
|
+
t.timestamps null: true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class AddForeignKeysForProductPromotionRules < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_foreign_key :spree_product_promotion_rules, :spree_products,
|
4
|
+
column: :product_id
|
5
|
+
|
6
|
+
add_foreign_key :spree_product_promotion_rules, :spree_promotion_rules,
|
7
|
+
column: :promotion_rule_id
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class ConvertSalePromotions < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
sale_promotions.update_all(apply_automatically: true)
|
4
|
+
end
|
5
|
+
|
6
|
+
def down
|
7
|
+
# intentionally left blank
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def sale_promotions
|
13
|
+
promo_table = Spree::Promotion.arel_table
|
14
|
+
code_table = Spree::PromotionCode.arel_table
|
15
|
+
|
16
|
+
promotion_code_join = promo_table.join(code_table, Arel::Nodes::OuterJoin).on(
|
17
|
+
promo_table[:id].eq(code_table[:promotion_id])
|
18
|
+
).join_sources
|
19
|
+
|
20
|
+
Spree::Promotion.includes(:promotion_rules).
|
21
|
+
joins(promotion_code_join).
|
22
|
+
where(
|
23
|
+
code_table[:value].eq(nil).and(
|
24
|
+
promo_table[:path].eq(nil)
|
25
|
+
)
|
26
|
+
).distinct
|
27
|
+
end
|
28
|
+
end
|
data/lib/spree/core.rb
CHANGED
@@ -92,6 +92,8 @@ require 'spree/core/controller_helpers/store'
|
|
92
92
|
require 'spree/core/controller_helpers/strong_parameters'
|
93
93
|
require 'spree/core/unreturned_item_charger'
|
94
94
|
require 'spree/core/role_configuration'
|
95
|
+
require 'spree/permission_sets'
|
96
|
+
require 'spree/deprecation'
|
95
97
|
|
96
98
|
require 'spree/mailer_previews/order_preview'
|
97
99
|
require 'spree/mailer_previews/carton_preview'
|
@@ -48,6 +48,13 @@ module Spree
|
|
48
48
|
product_properties_attributes: permitted_product_properties_attributes
|
49
49
|
]
|
50
50
|
end
|
51
|
+
|
52
|
+
def permitted_user_attributes
|
53
|
+
permitted_attributes.user_attributes + [
|
54
|
+
bill_address_attributes: permitted_address_attributes,
|
55
|
+
ship_address_attributes: permitted_address_attributes
|
56
|
+
]
|
57
|
+
end
|
51
58
|
end
|
52
59
|
end
|
53
60
|
end
|
data/lib/spree/core/engine.rb
CHANGED
@@ -93,7 +93,8 @@ module Spree
|
|
93
93
|
Spree::Promotion::Rules::OneUsePerUser,
|
94
94
|
Spree::Promotion::Rules::Taxon,
|
95
95
|
Spree::Promotion::Rules::NthOrder,
|
96
|
-
Spree::Promotion::Rules::OptionValue
|
96
|
+
Spree::Promotion::Rules::OptionValue,
|
97
|
+
Spree::Promotion::Rules::FirstRepeatPurchaseSince,
|
97
98
|
]
|
98
99
|
end
|
99
100
|
|
@@ -3,7 +3,7 @@ module Spree
|
|
3
3
|
class CartonPreview < ActionMailer::Preview
|
4
4
|
def shipped
|
5
5
|
carton = Carton.first
|
6
|
-
|
6
|
+
Spree::Config.carton_shipped_email_class.shipped_email(order: carton.orders.first, carton: carton)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spree/permission_sets/base'
|
2
|
+
require 'spree/permission_sets/configuration_display'
|
3
|
+
require 'spree/permission_sets/configuration_management'
|
4
|
+
require 'spree/permission_sets/dashboard_display'
|
5
|
+
require 'spree/permission_sets/default_customer'
|
6
|
+
require 'spree/permission_sets/order_display'
|
7
|
+
require 'spree/permission_sets/order_management'
|
8
|
+
require 'spree/permission_sets/product_display'
|
9
|
+
require 'spree/permission_sets/product_management'
|
10
|
+
require 'spree/permission_sets/promotion_display'
|
11
|
+
require 'spree/permission_sets/promotion_management'
|
12
|
+
require 'spree/permission_sets/report_display'
|
13
|
+
require 'spree/permission_sets/restricted_stock_display'
|
14
|
+
require 'spree/permission_sets/restricted_stock_management'
|
15
|
+
require 'spree/permission_sets/restricted_stock_transfer_display'
|
16
|
+
require 'spree/permission_sets/restricted_stock_transfer_management'
|
17
|
+
require 'spree/permission_sets/stock_display'
|
18
|
+
require 'spree/permission_sets/stock_management'
|
19
|
+
require 'spree/permission_sets/stock_transfer_display'
|
20
|
+
require 'spree/permission_sets/stock_transfer_management'
|
21
|
+
require 'spree/permission_sets/super_user'
|
22
|
+
require 'spree/permission_sets/user_display'
|
23
|
+
require 'spree/permission_sets/user_management'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -17,12 +17,13 @@ module Spree
|
|
17
17
|
can :display, ProductProperty
|
18
18
|
can :display, Property
|
19
19
|
can :create, Spree.user_class
|
20
|
-
can [:read, :update], Spree.user_class, id: user.id
|
20
|
+
can [:read, :update, :update_email], Spree.user_class, id: user.id
|
21
21
|
can :display, State
|
22
22
|
can :display, StockItem, stock_location: { active: true }
|
23
23
|
can :display, StockLocation, active: true
|
24
24
|
can :display, Taxon
|
25
25
|
can :display, Taxonomy
|
26
|
+
can [:save_in_address_book, :remove_from_address_book], Spree.user_class, id: user.id
|
26
27
|
can [:display, :view_out_of_stock], Variant
|
27
28
|
can :display, Zone
|
28
29
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -19,32 +19,42 @@ module Spree
|
|
19
19
|
class RestrictedStockTransferManagement < PermissionSets::Base
|
20
20
|
def activate!
|
21
21
|
if user.stock_locations.any?
|
22
|
-
can :display, Spree::StockLocation, id:
|
22
|
+
can :display, Spree::StockLocation, id: user_location_ids
|
23
23
|
can [:admin, :create], Spree::StockTransfer
|
24
|
-
can :display, Spree::StockTransfer, source_location_id:
|
25
|
-
can :display, Spree::StockTransfer, destination_location_id:
|
24
|
+
can :display, Spree::StockTransfer, source_location_id: source_location_ids
|
25
|
+
can :display, Spree::StockTransfer, destination_location_id: destination_location_ids
|
26
26
|
can :manage, Spree::StockTransfer,
|
27
|
-
source_location_id:
|
28
|
-
destination_location_id:
|
27
|
+
source_location_id: source_location_ids,
|
28
|
+
destination_location_id: destination_location_ids_with_undefined_destination
|
29
29
|
|
30
|
-
can :
|
30
|
+
can :transfer_from, Spree::StockLocation, id: source_location_ids
|
31
|
+
can :transfer_to, Spree::StockLocation, id: destination_location_ids
|
31
32
|
|
32
33
|
can :manage, Spree::TransferItem, stock_transfer: {
|
33
|
-
source_location_id:
|
34
|
-
destination_location_id:
|
34
|
+
source_location_id: source_location_ids,
|
35
|
+
destination_location_id: destination_location_ids_with_undefined_destination
|
35
36
|
}
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
40
|
private
|
40
41
|
|
41
|
-
def
|
42
|
-
|
43
|
-
@ids ||= user.stock_locations.pluck(:id)
|
42
|
+
def user_location_ids
|
43
|
+
@user_location_ids ||= user.stock_locations.pluck(:id)
|
44
44
|
end
|
45
45
|
|
46
|
+
# @note Meant to facilitate extension - override to define custom ids
|
47
|
+
def source_location_ids
|
48
|
+
user_location_ids
|
49
|
+
end
|
50
|
+
|
51
|
+
# @note Meant to facilitate extension - override to define custom ids
|
46
52
|
def destination_location_ids
|
47
|
-
|
53
|
+
user_location_ids
|
54
|
+
end
|
55
|
+
|
56
|
+
def destination_location_ids_with_undefined_destination
|
57
|
+
destination_location_ids + [nil]
|
48
58
|
end
|
49
59
|
end
|
50
60
|
end
|
File without changes
|
File without changes
|
File without changes
|