spree_promo 1.0.0.rc4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/db/migrate/20120119024707_namespace_promo_tables.rb +49 -29
- data/lib/spree/promo/engine.rb +0 -5
- metadata +14 -11
@@ -1,4 +1,36 @@
|
|
1
|
+
require 'spree/core/preference_rescue'
|
2
|
+
|
1
3
|
class NamespacePromoTables < ActiveRecord::Migration
|
4
|
+
|
5
|
+
def concat(str1, str2)
|
6
|
+
dbtype = Rails.configuration.database_configuration[Rails.env]['adapter'].to_sym
|
7
|
+
|
8
|
+
case dbtype
|
9
|
+
when :mysql, :mysql2
|
10
|
+
"CONCAT(#{str1}, #{str2})"
|
11
|
+
when :sqlserver
|
12
|
+
"(#{str1} + #{str2})"
|
13
|
+
else
|
14
|
+
"(#{str1} || #{str2})"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def update_column_data(table_names, column_name)
|
19
|
+
tables = Array.wrap(table_names)
|
20
|
+
tables.each do |table|
|
21
|
+
execute "UPDATE #{table} SET #{column_name} = #{concat("'Spree::'", column_name)}" +
|
22
|
+
" where #{column_name} NOT LIKE 'Spree::%' AND #{column_name} IS NOT NULL"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def replace_column_data(table_names, column_name)
|
27
|
+
tables = Array.wrap(table_names)
|
28
|
+
tables.each do |table|
|
29
|
+
execute "UPDATE #{table} SET #{column_name} = REPLACE(#{column_name}, 'Spree::', '') " +
|
30
|
+
" where #{column_name} LIKE 'Spree::%'"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
2
34
|
def self.up
|
3
35
|
# namespace promo tables
|
4
36
|
rename_table :promotion_actions, :spree_promotion_actions
|
@@ -7,59 +39,47 @@ class NamespacePromoTables < ActiveRecord::Migration
|
|
7
39
|
rename_table :promotion_action_line_items, :spree_promotion_action_line_items
|
8
40
|
rename_table :products_promotion_rules, :spree_products_promotion_rules
|
9
41
|
|
42
|
+
update_column_data('spree_promotion_actions', 'type')
|
43
|
+
update_column_data('spree_promotion_rules', 'type')
|
44
|
+
|
10
45
|
# add old promo preferences as columns
|
11
46
|
add_column :spree_activators, :usage_limit, :integer
|
12
47
|
add_column :spree_activators, :match_policy, :string, :default => 'all'
|
13
48
|
add_column :spree_activators, :code, :string
|
14
49
|
add_column :spree_activators, :advertise, :boolean, :default => false
|
15
50
|
|
16
|
-
Spree::
|
17
|
-
preference :usage_limit, :integer
|
18
|
-
preference :match_policy, :string, :default => 'all'
|
19
|
-
preference :code, :string
|
20
|
-
preference :advertise, :boolean, :default => false
|
21
|
-
end
|
51
|
+
Spree::Activator.reset_column_information
|
22
52
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
case pref.name
|
28
|
-
when 'code'
|
29
|
-
@promo.code = pref.value.to_s
|
30
|
-
@promo.name = pref.value.to_s
|
31
|
-
when 'advertise'
|
32
|
-
@promo.advertise = pref.value
|
33
|
-
when 'usage_limit'
|
34
|
-
@promo.usage_limit = pref.value
|
35
|
-
when 'match_policy'
|
36
|
-
@promo.match_policy = pref.value
|
37
|
-
end
|
38
|
-
@promo.event_name = Spree::Promotion.find(pref.owner_id).event_name
|
53
|
+
Spree::Preference.where(:owner_type => 'Spree::Activator').each do |preference|
|
54
|
+
unless Spree::Activator.exists? preference.owner_id
|
55
|
+
preference.destroy
|
56
|
+
next
|
39
57
|
end
|
40
|
-
|
58
|
+
|
59
|
+
@activator = Spree::Activator.find(preference.owner_id)
|
60
|
+
@activator.update_attribute(preference.name, preference.raw_value)
|
61
|
+
preference.destroy
|
41
62
|
end
|
42
63
|
|
43
|
-
|
44
|
-
Spree::Promotion.where(:code => nil).delete_all
|
64
|
+
Spree::PreferenceRescue.try
|
45
65
|
|
46
66
|
# This *should* be in the new_preferences migration inside of Core but...
|
47
67
|
# This is migration needs to have these keys around so that
|
48
68
|
# we can convert the promotions over correctly.
|
49
69
|
# So they hang around until we're *finally* done with them, since promo's
|
50
70
|
# migrations are copied over *after* core, and then we ditch them.
|
51
|
-
remove_column :spree_preferences, :name
|
52
|
-
remove_column :spree_preferences, :owner_id
|
53
|
-
remove_column :spree_preferences, :owner_type
|
54
71
|
remove_column :spree_preferences, :group_id
|
55
72
|
remove_column :spree_preferences, :group_type
|
56
73
|
end
|
57
74
|
|
58
75
|
def self.down
|
76
|
+
replace_column_data('spree_promotion_actions', 'type')
|
77
|
+
replace_column_data('spree_promotion_rules', 'type')
|
78
|
+
|
59
79
|
rename_table :spree_promotion_actions, :promotion_actions
|
60
80
|
rename_table :spree_promotion_rules, :promotion_rules
|
61
81
|
rename_table :spree_promotion_rules_users, :promotion_rules_users
|
62
82
|
rename_table :spree_promotion_action_line_items, :promotion_action_line_items
|
63
83
|
rename_table :spree_products_promotion_rules, :products_promotion_rules
|
64
84
|
end
|
65
|
-
end
|
85
|
+
end
|
data/lib/spree/promo/engine.rb
CHANGED
@@ -8,11 +8,6 @@ module Spree
|
|
8
8
|
Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')) do |c|
|
9
9
|
Rails.configuration.cache_classes ? require(c) : load(c)
|
10
10
|
end
|
11
|
-
|
12
|
-
Dir.glob(File.join(File.dirname(__FILE__), '../../../app/overrides/*.rb')) do |c|
|
13
|
-
Rails.configuration.cache_classes ? require(c) : load(c)
|
14
|
-
end
|
15
|
-
|
16
11
|
end
|
17
12
|
|
18
13
|
config.autoload_paths += %W(#{config.root}/lib)
|
metadata
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_promo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- David North
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
16
|
-
requirement: &
|
16
|
+
requirement: &70095898283920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.0.0
|
21
|
+
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70095898283920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: spree_auth
|
27
|
-
requirement: &
|
27
|
+
requirement: &70095898282920 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.0.0
|
32
|
+
version: 1.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70095898282920
|
36
36
|
description: Required dependency for Spree
|
37
37
|
email: david@spreecommerce.com
|
38
38
|
executables: []
|
@@ -128,9 +128,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
|
-
- - ! '
|
131
|
+
- - ! '>='
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
133
|
+
version: '0'
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
hash: 3112461834869644105
|
134
137
|
requirements:
|
135
138
|
- none
|
136
139
|
rubyforge_project:
|