diff --git a/src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake b/src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake index 7c70dc7..78281f1 100755 --- a/src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake +++ b/src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake @@ -3,7 +3,7 @@ namespace :software do desc "Creates SISP software template" task :create_sisp_template => :environment do - env = Environment.default + env = Environment.find_by_name("sisp") if env.present? template = Community.where(identifier: "sisp-software", environment_id: env).last @@ -11,23 +11,40 @@ namespace :software do template = Community.create!(name: "Sisp Software", identifier: "sisp-software", is_template: true, environment: env) template.update_layout_template("leftbar") - - template.boxes.find_by_position(2).blocks.destroy_all - - main_block = template.boxes.first.blocks.find_by_type("MainBlock") - main_block.display = "except_home_page" - main_block.save - - template.boxes.find_by_position(1).blocks << SoftwareInformationBlock.new(:display => "home_page_only") - template.boxes.find_by_position(1).blocks << SispTabDataBlock.new(:display => "home_page_only") - template.boxes.find_by_position(1).blocks << OrganizationRatingsBlock.new(:display => "home_page_only") - template.save! + create_blocks_box_1 template + create_blocks_box_2 template env.community_default_template = template env.save! end end + def create_blocks_box_1 template + box_1 = template.boxes.find_by_position(1) + box_1.blocks << SoftwareInformationBlock.new(:display => "home_page_only") + box_1.blocks << SispTabDataBlock.new(:display => "home_page_only") + box_1.blocks << OrganizationRatingsBlock.new(:display => "home_page_only") + + main_block = box_1.blocks.find_by_type("MainBlock") + main_block.display = "except_home_page" + main_block.save + end + + def create_blocks_box_2 template + box_2 = template.boxes.find_by_position(2) + box_2.blocks.destroy_all + box_2.blocks << LinkListBlock.new(:links => [{:name=>"Catálogo de Software Público", :address=>"/search/software_infos", :target=>"_self"}, + {:name=>"Comunidades", :address=>"/search/communities", :target=>"_self"}, + {:name=>"Ajuda", :address=>"/spb/ajuda", :target=>"_self"}]) + box_2.blocks << LinkListBlock.new(:title => "Software Público", + :links => [{:name=>"Entenda o que é", :address=>"/spb/entenda-o-que-e", :target=>"_self"}, + {:name=>"Inicie um projeto", :address=>"/spb/inicie-um-projeto", :target=>"_self"}, + {:name=>"Publique seu software", :address=>"/spb/publique-seu-software", :target=>"_self"}]) + box_2.blocks << LinkListBlock.new(:title => "Portal do SPB", + :links => [{:name=>"Sobre o Portal", :address=>"/spb/sobre-o-portal", :target=>"_self"}, + {:name=>"Notícias", :address=>"/spb/noticias", :target=>"_self"}]) + end + desc "Import sisp software from yml" task :import_sisp => :environment do -- libgit2 0.21.2