20150907190532_add_statistic_block_to_all_softwares.rb
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class AddStatisticBlockToAllSoftwares < ActiveRecord::Migration
def up
software_template = Community["software"]
if software_template
software_area_two = software_template.boxes.find_by_position 2
statistic_block_template = StatisticBlock.new :mirror => true, :move_modes => "none", :edit_modes => "none"
statistic_block_template.settings[:fixed] = true
statistic_block_template.display = "home_page_only"
statistic_block_template.save!
print "."
software_area_two.blocks << statistic_block_template
software_area_two.save!
print "."
# Puts the ratings block as the last one on area one
first_block_position = software_area_two.blocks.order(:position).first.position
statistic_block_template.position = first_block_position + 1
statistic_block_template.save!
print "."
end
Community.joins(:software_info).each do |software_community|
software_area_two = software_community.boxes.find_by_position 2
print "."
statistic_block = StatisticBlock.new :move_modes => "none", :edit_modes => "none"
statistic_block.settings[:fixed] = true
statistic_block.display = "home_page_only"
statistic_block.mirror_block_id = statistic_block_template.id
statistic_block.save!
print "."
software_area_two.blocks << statistic_block
software_area_two.save!
print "."
# Puts the ratings block as the last one on area one
first_block_position = software_area_two.blocks.order(:position).first.position
statistic_block.position = first_block_position + 1
statistic_block.save!
print "."
end
puts ""
end
def down
say "This can't be reverted"
end
end