Commit f75ad204938ea820ca98865d5b118c855a3e413f
1 parent
cce16a6b
Exists in
sisp_simple_version
Finishes sisp import and template creation tasks
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com> Signed-off-by: Gustavo Coelho <gust.rod.coelho@gmail.com>
Showing
1 changed file
with
43 additions
and
23 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake
| 1 | # encoding: UTF-8 | 1 | # encoding: UTF-8 |
| 2 | 2 | ||
| 3 | -namespace :software do | 3 | +namespace :sisp do |
| 4 | + desc "Creates SISP env, template, and import data" | ||
| 5 | + task :all => :environment do | ||
| 6 | + Rake::Task['sisp:create_env'].invoke | ||
| 7 | + Rake::Task['sisp:create_template'].invoke | ||
| 8 | + Rake::Task['sisp:import_data'].invoke | ||
| 9 | + end | ||
| 10 | + | ||
| 11 | + desc "Creates the SISP Environment" | ||
| 12 | + task :create_env => :environment do | ||
| 13 | + env = Environment.create!(name: "SISP") | ||
| 14 | + env.domains << Domain.create!(name: "dev.sisp.gov.br") | ||
| 15 | + create_link_blocks env | ||
| 16 | + | ||
| 17 | + puts "SISP Environment created" | ||
| 18 | + end | ||
| 19 | + | ||
| 20 | + def create_link_blocks template | ||
| 21 | + box_2 = template.boxes.find_by_position(2) | ||
| 22 | + box_2.blocks.destroy_all | ||
| 23 | + box_2.blocks << LinkListBlock.new(:mirror => true, | ||
| 24 | + :links => [{:name=>"Catálogo de Software", :address=>"/search/sisp", :target=>"_self"}, | ||
| 25 | + {:name=>"Ajuda", :address=>"/", :target=>"_self"}]) | ||
| 26 | + box_2.blocks << LinkListBlock.new(:title => "Software SISP", :mirror => true, | ||
| 27 | + :links => [{:name=>"Publique seu Software", :address=>"/", :target=>"_self"}, | ||
| 28 | + {:name=>"Vídeos", :address=>"/", :target=>"_self"}]) | ||
| 29 | + box_2.blocks << LinkListBlock.new(:title => "Portal do SISP", :mirror => true, | ||
| 30 | + :links => [{:name=>"Sobre o Portal", :address=>"/", :target=>"_self"}, | ||
| 31 | + {:name=>"Contato", :address=>"/", :target=>"_self"}, | ||
| 32 | + {:name=>"Notícias", :address=>"/", :target=>"_self"}]) | ||
| 33 | + end | ||
| 34 | + | ||
| 4 | desc "Creates SISP software template" | 35 | desc "Creates SISP software template" |
| 5 | - task :create_sisp_template => :environment do | ||
| 6 | - env = Environment.find_by_name("sisp") | 36 | + task :create_template => :environment do |
| 37 | + env = Environment.find_by_name("SISP") | ||
| 7 | 38 | ||
| 8 | if env.present? | 39 | if env.present? |
| 9 | template = Community.where(identifier: "sisp-software", environment_id: env).last | 40 | template = Community.where(identifier: "sisp-software", environment_id: env).last |
| @@ -11,15 +42,17 @@ namespace :software do | @@ -11,15 +42,17 @@ namespace :software do | ||
| 11 | template = Community.create!(name: "Sisp Software", identifier: "sisp-software", is_template: true, environment: env) | 42 | template = Community.create!(name: "Sisp Software", identifier: "sisp-software", is_template: true, environment: env) |
| 12 | 43 | ||
| 13 | template.update_layout_template("leftbar") | 44 | template.update_layout_template("leftbar") |
| 14 | - create_blocks_box_1 template | ||
| 15 | - create_blocks_box_2 template | 45 | + create_template_blocks template |
| 46 | + create_link_blocks template | ||
| 16 | 47 | ||
| 17 | env.community_default_template = template | 48 | env.community_default_template = template |
| 18 | env.save! | 49 | env.save! |
| 19 | end | 50 | end |
| 51 | + | ||
| 52 | + puts "SISP Template created" | ||
| 20 | end | 53 | end |
| 21 | 54 | ||
| 22 | - def create_blocks_box_1 template | 55 | + def create_template_blocks template |
| 23 | box_1 = template.boxes.find_by_position(1) | 56 | box_1 = template.boxes.find_by_position(1) |
| 24 | box_1.blocks << SoftwareInformationBlock.new(:display => "home_page_only") | 57 | box_1.blocks << SoftwareInformationBlock.new(:display => "home_page_only") |
| 25 | box_1.blocks << SispTabDataBlock.new(:display => "home_page_only") | 58 | box_1.blocks << SispTabDataBlock.new(:display => "home_page_only") |
| @@ -30,26 +63,11 @@ namespace :software do | @@ -30,26 +63,11 @@ namespace :software do | ||
| 30 | main_block.save | 63 | main_block.save |
| 31 | end | 64 | end |
| 32 | 65 | ||
| 33 | - def create_blocks_box_2 template | ||
| 34 | - box_2 = template.boxes.find_by_position(2) | ||
| 35 | - box_2.blocks.destroy_all | ||
| 36 | - box_2.blocks << LinkListBlock.new(:links => [{:name=>"Catálogo de Software Público", :address=>"/search/software_infos", :target=>"_self"}, | ||
| 37 | - {:name=>"Comunidades", :address=>"/search/communities", :target=>"_self"}, | ||
| 38 | - {:name=>"Ajuda", :address=>"/spb/ajuda", :target=>"_self"}]) | ||
| 39 | - box_2.blocks << LinkListBlock.new(:title => "Software Público", | ||
| 40 | - :links => [{:name=>"Entenda o que é", :address=>"/spb/entenda-o-que-e", :target=>"_self"}, | ||
| 41 | - {:name=>"Inicie um projeto", :address=>"/spb/inicie-um-projeto", :target=>"_self"}, | ||
| 42 | - {:name=>"Publique seu software", :address=>"/spb/publique-seu-software", :target=>"_self"}]) | ||
| 43 | - box_2.blocks << LinkListBlock.new(:title => "Portal do SPB", | ||
| 44 | - :links => [{:name=>"Sobre o Portal", :address=>"/spb/sobre-o-portal", :target=>"_self"}, | ||
| 45 | - {:name=>"Notícias", :address=>"/spb/noticias", :target=>"_self"}]) | ||
| 46 | - end | ||
| 47 | - | ||
| 48 | desc "Import sisp software from yml" | 66 | desc "Import sisp software from yml" |
| 49 | - task :import_sisp => :environment do | 67 | + task :import_data => :environment do |
| 50 | 68 | ||
| 51 | $imported_data = YAML.load_file('plugins/software_communities/public/static/sisp-catalog.yml') | 69 | $imported_data = YAML.load_file('plugins/software_communities/public/static/sisp-catalog.yml') |
| 52 | - $env = Environment.default #TODO change this to correct environment | 70 | + $env = Environment.find_by_name("SISP") |
| 53 | 71 | ||
| 54 | $software_category = Category.find_by_name("Software") | 72 | $software_category = Category.find_by_name("Software") |
| 55 | $software_category ||= Category.create(:name => "Software", :environment => $env) | 73 | $software_category ||= Category.create(:name => "Software", :environment => $env) |
| @@ -104,6 +122,7 @@ def create_sisp_community name | @@ -104,6 +122,7 @@ def create_sisp_community name | ||
| 104 | 122 | ||
| 105 | community.identifier = identifier | 123 | community.identifier = identifier |
| 106 | community.template = $sisp_template | 124 | community.template = $sisp_template |
| 125 | + community.environment = $env | ||
| 107 | 126 | ||
| 108 | community.save! | 127 | community.save! |
| 109 | community | 128 | community |
| @@ -176,6 +195,7 @@ def create_institution sisp_hash | @@ -176,6 +195,7 @@ def create_institution sisp_hash | ||
| 176 | institution_community.country = "BR" | 195 | institution_community.country = "BR" |
| 177 | institution_community.state = "DF" | 196 | institution_community.state = "DF" |
| 178 | institution_community.city = "Unknown" | 197 | institution_community.city = "Unknown" |
| 198 | + institution_community.environment = $env | ||
| 179 | institution_community.save! | 199 | institution_community.save! |
| 180 | 200 | ||
| 181 | institution.community = institution_community | 201 | institution.community = institution_community |