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 78281f1..674ed9d 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 @@ -1,9 +1,40 @@ # encoding: UTF-8 -namespace :software do +namespace :sisp do + desc "Creates SISP env, template, and import data" + task :all => :environment do + Rake::Task['sisp:create_env'].invoke + Rake::Task['sisp:create_template'].invoke + Rake::Task['sisp:import_data'].invoke + end + + desc "Creates the SISP Environment" + task :create_env => :environment do + env = Environment.create!(name: "SISP") + env.domains << Domain.create!(name: "dev.sisp.gov.br") + create_link_blocks env + + puts "SISP Environment created" + end + + def create_link_blocks template + box_2 = template.boxes.find_by_position(2) + box_2.blocks.destroy_all + box_2.blocks << LinkListBlock.new(:mirror => true, + :links => [{:name=>"Catálogo de Software", :address=>"/search/sisp", :target=>"_self"}, + {:name=>"Ajuda", :address=>"/", :target=>"_self"}]) + box_2.blocks << LinkListBlock.new(:title => "Software SISP", :mirror => true, + :links => [{:name=>"Publique seu Software", :address=>"/", :target=>"_self"}, + {:name=>"Vídeos", :address=>"/", :target=>"_self"}]) + box_2.blocks << LinkListBlock.new(:title => "Portal do SISP", :mirror => true, + :links => [{:name=>"Sobre o Portal", :address=>"/", :target=>"_self"}, + {:name=>"Contato", :address=>"/", :target=>"_self"}, + {:name=>"Notícias", :address=>"/", :target=>"_self"}]) + end + desc "Creates SISP software template" - task :create_sisp_template => :environment do - env = Environment.find_by_name("sisp") + task :create_template => :environment do + env = Environment.find_by_name("SISP") if env.present? template = Community.where(identifier: "sisp-software", environment_id: env).last @@ -11,15 +42,17 @@ namespace :software do template = Community.create!(name: "Sisp Software", identifier: "sisp-software", is_template: true, environment: env) template.update_layout_template("leftbar") - create_blocks_box_1 template - create_blocks_box_2 template + create_template_blocks template + create_link_blocks template env.community_default_template = template env.save! end + + puts "SISP Template created" end - def create_blocks_box_1 template + def create_template_blocks 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") @@ -30,26 +63,11 @@ namespace :software do 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 + task :import_data => :environment do $imported_data = YAML.load_file('plugins/software_communities/public/static/sisp-catalog.yml') - $env = Environment.default #TODO change this to correct environment + $env = Environment.find_by_name("SISP") $software_category = Category.find_by_name("Software") $software_category ||= Category.create(:name => "Software", :environment => $env) @@ -104,6 +122,7 @@ def create_sisp_community name community.identifier = identifier community.template = $sisp_template + community.environment = $env community.save! community @@ -176,6 +195,7 @@ def create_institution sisp_hash institution_community.country = "BR" institution_community.state = "DF" institution_community.city = "Unknown" + institution_community.environment = $env institution_community.save! institution.community = institution_community -- libgit2 0.21.2