Commit c070230f21d0d81c2f7df62ada85afbeaa1d1634
1 parent
d3f7fbfe
Exists in
master
and in
79 other branches
Add wiki block to all softwares communities migration
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Simiao Carvalho <simiaosimis@gmail.com>
Showing
1 changed file
with
54 additions
and
0 deletions
Show diff stats
db/migrate/20150909191415_add_wiki_block_to_all_softwares_communities.rb
0 → 100644
| ... | ... | @@ -0,0 +1,54 @@ |
| 1 | +class AddWikiBlockToAllSoftwaresCommunities < ActiveRecord::Migration | |
| 2 | + def up | |
| 3 | + software_template = Community["software"] | |
| 4 | + | |
| 5 | + if software_template | |
| 6 | + software_area_two = software_template.boxes.find_by_position 2 | |
| 7 | + | |
| 8 | + wiki_block_template = WikiBlock.new :mirror => true, :move_modes => "none", :edit_modes => "none" | |
| 9 | + wiki_block_template.settings[:fixed] = true | |
| 10 | + wiki_block_template.save! | |
| 11 | + print "." | |
| 12 | + | |
| 13 | + software_area_two.blocks << wiki_block_template | |
| 14 | + software_area_two.save! | |
| 15 | + print "." | |
| 16 | + | |
| 17 | + # Puts the ratings block as the last one on area one | |
| 18 | + repository_block = software_area_two.blocks.find_by_type("RepositoryBlock") | |
| 19 | + if !repository_block.nil? | |
| 20 | + wiki_block_template.position = repository_block.position + 1 | |
| 21 | + wiki_block_template.save! | |
| 22 | + print "." | |
| 23 | + end | |
| 24 | + end | |
| 25 | + | |
| 26 | + Community.joins(:software_info).each do |software_community| | |
| 27 | + software_area_two = software_community.boxes.find_by_position 2 | |
| 28 | + print "." | |
| 29 | + | |
| 30 | + wiki_block = WikiBlock.new :move_modes => "none", :edit_modes => "none" | |
| 31 | + wiki_block.settings[:fixed] = true | |
| 32 | + wiki_block.mirror_block_id = wiki_block_template.id | |
| 33 | + wiki_block.save! | |
| 34 | + print "." | |
| 35 | + | |
| 36 | + software_area_two.blocks << wiki_block | |
| 37 | + software_area_two.save! | |
| 38 | + print "." | |
| 39 | + | |
| 40 | + repository_block = software_area_two.blocks.find_by_type("RepositoryBlock") | |
| 41 | + if !repository_block.nil? | |
| 42 | + wiki_block.position = repository_block.position + 1 | |
| 43 | + wiki_block.save! | |
| 44 | + print "." | |
| 45 | + end | |
| 46 | + end | |
| 47 | + | |
| 48 | + puts "" | |
| 49 | + end | |
| 50 | + | |
| 51 | + def down | |
| 52 | + say "This can't be reverted" | |
| 53 | + end | |
| 54 | +end | ... | ... |