Commit 720c7f601c70873e65e09935204869c947536a64

Authored by Arthur Esposte
2 parents 3edd005a 7377bb8a
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Merge branch 'master' of portal.softwarepublico.gov.br:softwarepublico/spb_migrations

db/migrate/20150727161511_change_software_layout.rb
1 1 class ChangeSoftwareLayout < ActiveRecord::Migration
2 2 def up
  3 + software_template = Community["software"]
  4 + if software_template
  5 + change_layout(software_template)
  6 + end
  7 +
3 8 softwares = SoftwareInfo.all
4 9 softwares.each do |software|
5   - software.community.layout_template = "lefttopright"
6   - print "." if software.community.save
7   - boxToMove = software.community.boxes.where(:position => 1).first
8   - blockToMove = boxToMove.blocks.where(:type => "SoftwareInformationBlock").first
9   - if blockToMove
10   - newBox = software.community.boxes.where(:position => 4).first
11   - blockToMove.box = newBox
12   - print "." if blockToMove.save
13   - end
  10 + change_layout(software.community)
14 11 end
  12 +
  13 + puts ""
15 14 end
16 15  
17 16 def down
18 17 end
  18 +
  19 + def change_layout(community)
  20 + community.layout_template = "lefttopright"
  21 + print "." if community.save
  22 + boxToMove = community.boxes.where(:position => 1).first
  23 + blockToMove = boxToMove.blocks.where(:type => "SoftwareInformationBlock").first
  24 + if blockToMove
  25 + newBox = community.boxes.where(:position => 4).first
  26 + blockToMove.box = newBox
  27 + print "." if blockToMove.save
  28 + end
  29 + end
19 30 end
... ...
db/migrate/20150904174335_swap_softwares_blocks_between_areas_2_and_3.rb 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +class SwapSoftwaresBlocksBetweenAreas2And3 < ActiveRecord::Migration
  2 + def up
  3 + software_template = Community["software"]
  4 + if software_template
  5 + swap_software_blocks_between_areas_2_and_3(software_template)
  6 + end
  7 +
  8 + Community.joins(:software_info).each do |software_community|
  9 + swap_software_blocks_between_areas_2_and_3(software_community)
  10 + end
  11 + puts ""
  12 + end
  13 +
  14 + def down
  15 + say "This can't be reverted"
  16 + end
  17 +
  18 + def swap_software_blocks_between_areas_2_and_3(software_community)
  19 + print "."
  20 +
  21 + # Get areas 2 and 3
  22 + box_area_two = software_community.boxes.find_by_position 2
  23 + box_area_three = software_community.boxes.find_by_position 3
  24 +
  25 + # Get all ids of blocks from areas 2 and 3
  26 + blocks_ids_from_area_two = box_area_two.blocks.select(:id).map(&:id)
  27 + blocks_ids_from_area_three = box_area_three.blocks.select(:id).map(&:id)
  28 +
  29 + # Swap blocks from area 2 to 3
  30 + Block.update_all({:box_id=>box_area_three.id}, ["id IN (?)", blocks_ids_from_area_two])
  31 +
  32 + # Swap blocks from area 3 to 2
  33 + Block.update_all({:box_id=>box_area_two.id}, ["id IN (?)", blocks_ids_from_area_three])
  34 + end
  35 +end
... ...
db/migrate/20150904181508_add_organization_ratings_block_to_all_softwares_communities.rb 0 → 100644
... ... @@ -0,0 +1,53 @@
  1 +class AddOrganizationRatingsBlockToAllSoftwaresCommunities < ActiveRecord::Migration
  2 + def up
  3 + software_template = Community["software"]
  4 +
  5 + if software_template
  6 + software_area_one = software_template.boxes.find_by_position 1
  7 +
  8 + template_ratings_block = OrganizationRatingsBlock.new :mirror => true, :move_modes => "none", :edit_modes => "none"
  9 + template_ratings_block.settings[:fixed] = true
  10 + template_ratings_block.display = "home_page_only"
  11 + template_ratings_block.save!
  12 + print "."
  13 +
  14 + software_area_one.blocks << template_ratings_block
  15 + software_area_one.save!
  16 + print "."
  17 +
  18 + # Puts the ratings block as the last one on area one
  19 + last_block_position = software_area_one.blocks.order(:position).last.position
  20 + template_ratings_block.position = last_block_position + 1
  21 + template_ratings_block.save!
  22 + print "."
  23 + end
  24 +
  25 + Community.joins(:software_info).each do |software_community|
  26 + software_area_one = software_community.boxes.find_by_position 1
  27 + print "."
  28 +
  29 + ratings_block = OrganizationRatingsBlock.new :move_modes => "none", :edit_modes => "none"
  30 + ratings_block.settings[:fixed] = true
  31 + ratings_block.display = "home_page_only"
  32 + ratings_block.mirror_block_id = template_ratings_block.id
  33 + ratings_block.save!
  34 + print "."
  35 +
  36 + software_area_one.blocks << ratings_block
  37 + software_area_one.save!
  38 + print "."
  39 +
  40 + # Puts the ratings block as the last one on area one
  41 + last_block_position = software_area_one.blocks.order(:position).last.position
  42 + ratings_block.position = last_block_position + 1
  43 + ratings_block.save!
  44 + print "."
  45 + end
  46 +
  47 + puts ""
  48 + end
  49 +
  50 + def down
  51 + say "This can't be reverted"
  52 + end
  53 +end
... ...
db/migrate/20150904202116_add_software_tab_data_block_to_all_softwares.rb 0 → 100644
... ... @@ -0,0 +1,52 @@
  1 +class AddSoftwareTabDataBlockToAllSoftwares < ActiveRecord::Migration
  2 + def up
  3 + software_template = Community["software"]
  4 + if software_template
  5 + software_area_one = software_template.boxes.find_by_position 1
  6 +
  7 + template_soft_tab_block = SoftwareTabDataBlock.new :mirror => true, :move_modes => "none", :edit_modes => "none"
  8 + template_soft_tab_block.settings[:fixed] = true
  9 + template_soft_tab_block.display = "except_home_page"
  10 + template_soft_tab_block.save!
  11 + print "."
  12 +
  13 + software_area_one.blocks << template_soft_tab_block
  14 + software_area_one.save!
  15 + print "."
  16 +
  17 + # Puts the ratings block as the last one on area one
  18 + last_block_position = software_area_one.blocks.order(:position).last.position
  19 + template_soft_tab_block.position = last_block_position + 1
  20 + template_soft_tab_block.save!
  21 + print "."
  22 + end
  23 +
  24 + Community.joins(:software_info).each do |software_community|
  25 + software_area_one = software_community.boxes.find_by_position 1
  26 + print "."
  27 +
  28 + soft_tab_block = SoftwareTabDataBlock.new :move_modes => "none", :edit_modes => "none"
  29 + soft_tab_block.settings[:fixed] = true
  30 + soft_tab_block.display = "except_home_page"
  31 + soft_tab_block.mirror_block_id = template_soft_tab_block.id
  32 + soft_tab_block.save!
  33 + print "."
  34 +
  35 + software_area_one.blocks << soft_tab_block
  36 + software_area_one.save!
  37 + print "."
  38 +
  39 + # Puts the ratings block as the last one on area one
  40 + last_block_position = software_area_one.blocks.order(:position).last.position
  41 + soft_tab_block.position = last_block_position + 1
  42 + soft_tab_block.save!
  43 + print "."
  44 + end
  45 +
  46 + puts ""
  47 + end
  48 +
  49 + def down
  50 + say "This can't be reverted"
  51 + end
  52 +end
... ...
db/migrate/20150907190532_add_statistic_block_to_all_softwares.rb 0 → 100644
... ... @@ -0,0 +1,53 @@
  1 +class AddStatisticBlockToAllSoftwares < 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 + statistic_block_template = StatisticBlock.new :mirror => true, :move_modes => "none", :edit_modes => "none"
  9 + statistic_block_template.settings[:fixed] = true
  10 + statistic_block_template.display = "home_page_only"
  11 + statistic_block_template.save!
  12 + print "."
  13 +
  14 + software_area_two.blocks << statistic_block_template
  15 + software_area_two.save!
  16 + print "."
  17 +
  18 + # Puts the ratings block as the last one on area one
  19 + first_block_position = software_area_two.blocks.order(:position).first.position
  20 + statistic_block_template.position = first_block_position + 1
  21 + statistic_block_template.save!
  22 + print "."
  23 + end
  24 +
  25 + Community.joins(:software_info).each do |software_community|
  26 + software_area_two = software_community.boxes.find_by_position 2
  27 + print "."
  28 +
  29 + statistic_block = StatisticBlock.new :move_modes => "none", :edit_modes => "none"
  30 + statistic_block.settings[:fixed] = true
  31 + statistic_block.display = "home_page_only"
  32 + statistic_block.mirror_block_id = statistic_block_template.id
  33 + statistic_block.save!
  34 + print "."
  35 +
  36 + software_area_two.blocks << statistic_block
  37 + software_area_two.save!
  38 + print "."
  39 +
  40 + # Puts the ratings block as the last one on area one
  41 + first_block_position = software_area_two.blocks.order(:position).first.position
  42 + statistic_block.position = first_block_position + 1
  43 + statistic_block.save!
  44 + print "."
  45 + end
  46 +
  47 + puts ""
  48 + end
  49 +
  50 + def down
  51 + say "This can't be reverted"
  52 + end
  53 +end
... ...
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
  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
... ...
db/migrate/20150910133925_add_community_block_in_place_of_profile_image_block.rb 0 → 100644
... ... @@ -0,0 +1,63 @@
  1 +class AddCommunityBlockInPlaceOfProfileImageBlock < ActiveRecord::Migration
  2 + def up
  3 + software_template = Community['software']
  4 +
  5 + software_area_two = software_template.boxes.find_by_position 2
  6 +
  7 + community_block_template = CommunityBlock.new :mirror => true, :move_modes => "none", :edit_modes => "none"
  8 + community_block_template.settings[:fixed] = true
  9 + community_block_template.display = "except_home_page"
  10 + community_block_template.save!
  11 + print "."
  12 +
  13 + software_area_two.blocks << community_block_template
  14 + software_area_two.save!
  15 + print "."
  16 +
  17 + profile_image_block = software_area_two.blocks.find_by_type("ProfileImageBlock")
  18 + if !profile_image_block.nil?
  19 + community_block_template.position = profile_image_block.position
  20 + community_block_template.save!
  21 + print "."
  22 +
  23 + profile_image_block.destroy
  24 + print "."
  25 + end
  26 +
  27 + Community.joins(:software_info).each do |software_community|
  28 + software_area_two = software_community.boxes.find_by_position 2
  29 + print "."
  30 +
  31 + community_block = CommunityBlock.new :mirror => true, :move_modes => "none", :edit_modes => "none"
  32 + community_block.settings[:fixed] = true
  33 + community_block.display = "except_home_page"
  34 + community_block.mirror_block_id = community_block_template.id
  35 + community_block.save!
  36 + print "."
  37 +
  38 + software_area_two.blocks << community_block
  39 + software_area_two.save!
  40 + print "."
  41 +
  42 + profile_image_block = software_area_two.blocks.find_by_type("ProfileImageBlock")
  43 + if !profile_image_block.nil?
  44 + community_block.position = profile_image_block.position
  45 + community_block.save!
  46 + print "."
  47 +
  48 + profile_image_block.destroy
  49 + print "."
  50 +
  51 + # Put all link list blocks to behind
  52 + link_list_blocks = software_area_two.blocks.where(:type=>"LinkListBlock", :position=>1)
  53 + link_list_blocks.update_all :position => 3
  54 + end
  55 + end
  56 +
  57 + puts ""
  58 + end
  59 +
  60 + def down
  61 + say "This can't be reverted"
  62 + end
  63 +end
... ...