Commit 823ea6915186a79ed4e39ff72ff8ac7bad491b36

Authored by Gabriel Silva
1 parent b5a7adfd

Adding LinkListBlocks to SISP software template

Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake
... ... @@ -3,7 +3,7 @@
3 3 namespace :software do
4 4 desc "Creates SISP software template"
5 5 task :create_sisp_template => :environment do
6   - env = Environment.default
  6 + env = Environment.find_by_name("sisp")
7 7  
8 8 if env.present?
9 9 template = Community.where(identifier: "sisp-software", environment_id: env).last
... ... @@ -11,23 +11,40 @@ namespace :software do
11 11 template = Community.create!(name: "Sisp Software", identifier: "sisp-software", is_template: true, environment: env)
12 12  
13 13 template.update_layout_template("leftbar")
14   -
15   - template.boxes.find_by_position(2).blocks.destroy_all
16   -
17   - main_block = template.boxes.first.blocks.find_by_type("MainBlock")
18   - main_block.display = "except_home_page"
19   - main_block.save
20   -
21   - template.boxes.find_by_position(1).blocks << SoftwareInformationBlock.new(:display => "home_page_only")
22   - template.boxes.find_by_position(1).blocks << SispTabDataBlock.new(:display => "home_page_only")
23   - template.boxes.find_by_position(1).blocks << OrganizationRatingsBlock.new(:display => "home_page_only")
24   - template.save!
  14 + create_blocks_box_1 template
  15 + create_blocks_box_2 template
25 16  
26 17 env.community_default_template = template
27 18 env.save!
28 19 end
29 20 end
30 21  
  22 + def create_blocks_box_1 template
  23 + box_1 = template.boxes.find_by_position(1)
  24 + box_1.blocks << SoftwareInformationBlock.new(:display => "home_page_only")
  25 + box_1.blocks << SispTabDataBlock.new(:display => "home_page_only")
  26 + box_1.blocks << OrganizationRatingsBlock.new(:display => "home_page_only")
  27 +
  28 + main_block = box_1.blocks.find_by_type("MainBlock")
  29 + main_block.display = "except_home_page"
  30 + main_block.save
  31 + end
  32 +
  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 +
31 48 desc "Import sisp software from yml"
32 49 task :import_sisp => :environment do
33 50  
... ...