Commit b5a7adfd00b15ad4c2fc0be716001305d5604608

Authored by Luciano Prestes
1 parent 003bfdd8

Update template of sisp software into import_sisp_software task

Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake
@@ -3,16 +3,24 @@ @@ -3,16 +3,24 @@
3 namespace :software do 3 namespace :software do
4 desc "Creates SISP software template" 4 desc "Creates SISP software template"
5 task :create_sisp_template => :environment do 5 task :create_sisp_template => :environment do
6 - env = Environment.find_by_name("sisp") 6 + env = Environment.default
7 7
8 if env.present? 8 if env.present?
9 template = Community.where(identifier: "sisp-software", environment_id: env).last 9 template = Community.where(identifier: "sisp-software", environment_id: env).last
10 - template ||= Community.create!(name: "Sisp Software", identifier: "sisp-software", is_template: true, environment: env) 10 + template.destroy if template
  11 + template = Community.create!(name: "Sisp Software", identifier: "sisp-software", is_template: true, environment: env)
11 12
12 - template.boxes.find_by_position(1).blocks = []  
13 - template.boxes.find_by_position(1).blocks << SoftwareInformationBlock.new  
14 - template.boxes.find_by_position(1).blocks << SispTabDataBlock.new  
15 - template.boxes.find_by_position(1).blocks << OrganizationRatingsBlock.new 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")
16 template.save! 24 template.save!
17 25
18 env.community_default_template = template 26 env.community_default_template = template