Commit 712caca696153c3114a20a366b556b7afff4c4f1
Committed by
Paulo Tada
1 parent
d1a1242a
Exists in
master
and in
17 other branches
Sisp task improvements
- Splited in two tasks, one for creating sisp env and another to import data Signed-off-by: Rodrigo Souto <rodrigo@colivre.coop.br> Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br> Signed-off-by: Paulo Tada <paulohtfs@gmail.com>
Showing
1 changed file
with
16 additions
and
30 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake
| 1 | 1 | # encoding: UTF-8 |
| 2 | 2 | |
| 3 | 3 | namespace :sisp do |
| 4 | - desc "Creates SISP env, template, and import data" | |
| 5 | - task :all => :environment do | |
| 4 | + desc "Creates SISP env and templates" | |
| 5 | + task :prepare => :environment do | |
| 6 | 6 | unless ENV["DOMAIN"].present? |
| 7 | 7 | puts "You didn't choose any domain. The default domain is 'novo.sisp.gov.br'" |
| 8 | - puts "You can run rake sisp:all DOMAIN=domain.url" | |
| 9 | - puts "Continue and create SISP Environment with default domain? (y/N)" | |
| 10 | - response = $stdin.gets.strip | |
| 11 | - | |
| 12 | - unless ['y', 'yes'].include?(response.downcase) | |
| 13 | - puts "*** ABORTED." | |
| 14 | - exit 1 | |
| 15 | - end | |
| 8 | + puts "You can run rake sisp:prepare DOMAIN=domain.url to add a domain" | |
| 16 | 9 | end |
| 17 | 10 | |
| 18 | 11 | unless ENV["ADMINUSER"].present? |
| 19 | 12 | puts "You didn't enter any user to be selected from the default Environment" |
| 20 | - puts "You can run rake sisp:all ADMINUSER=jose" | |
| 21 | - puts "Continue and create SISP Environment without an admin user? (y/N)" | |
| 22 | - response = $stdin.gets.strip | |
| 23 | - | |
| 24 | - unless ['y', 'yes'].include?(response.downcase) | |
| 25 | - puts "*** ABORTED." | |
| 26 | - exit 1 | |
| 27 | - end | |
| 13 | + puts "You can run rake sisp:prepare ADMINUSER=jose" | |
| 28 | 14 | end |
| 29 | 15 | |
| 30 | 16 | Rake::Task['sisp:create_env'].invoke |
| 31 | 17 | Rake::Task['noosfero:plugins:enable_all'].invoke |
| 32 | 18 | Rake::Task['sisp:create_template'].invoke |
| 33 | - Rake::Task['sisp:import_data'].invoke | |
| 34 | 19 | end |
| 35 | 20 | |
| 21 | + desc "Create SISP environment and import data" | |
| 22 | + task :all => [:prepare, :import_data] | |
| 23 | + | |
| 36 | 24 | desc "Creates the SISP Environment" |
| 37 | 25 | task :create_env => :environment do |
| 38 | 26 | env = Environment.find_or_create_by_name("SISP") |
| ... | ... | @@ -56,15 +44,8 @@ namespace :sisp do |
| 56 | 44 | sisp_user.save |
| 57 | 45 | sisp_user.activate |
| 58 | 46 | env.add_admin sisp_user.person |
| 59 | - puts "SISP admin user created with success!" | |
| 60 | - puts "Type the password for this user" | |
| 61 | - $stdin.echo = false | |
| 62 | - sisp_user.password = $stdin.gets.strip | |
| 63 | - puts "Type the password confirmation" | |
| 64 | - sisp_user.password_confirmation = $stdin.gets.strip | |
| 65 | - | |
| 66 | - puts "Password not changed! Enter rails console and make it manually" unless sisp_user.save | |
| 67 | - $stdin.echo = true | |
| 47 | + | |
| 48 | + puts "User created with a random password. You can change in the console." unless sisp_user.save | |
| 68 | 49 | else |
| 69 | 50 | puts "\nWARNING!!!!!!***********************************************" |
| 70 | 51 | puts "No user found with the given login '#{ENV['ADMINUSER']}'.... skipping" |
| ... | ... | @@ -104,7 +85,7 @@ namespace :sisp do |
| 104 | 85 | template = Community.create!(name: "Sisp", identifier: "sisp", is_template: true, environment: env) |
| 105 | 86 | |
| 106 | 87 | template.home_page = template.blog |
| 107 | - template.update_layout_template("leftbar") | |
| 88 | + template.update_layout_template("nosidebars") | |
| 108 | 89 | template.save |
| 109 | 90 | |
| 110 | 91 | create_template_blocks template |
| ... | ... | @@ -134,10 +115,14 @@ namespace :sisp do |
| 134 | 115 | |
| 135 | 116 | desc "Import sisp software from yml" |
| 136 | 117 | task :import_data => :environment do |
| 137 | - | |
| 138 | 118 | $imported_data = YAML.load_file('plugins/software_communities/public/static/sisp-catalog.yml') |
| 139 | 119 | $env = Environment.find_by_name("SISP") |
| 120 | + unless $env | |
| 121 | + puts "SISP environment not FOUND!" | |
| 122 | + exit 1 | |
| 123 | + end | |
| 140 | 124 | |
| 125 | + $license = LicenseInfo.find_or_create_by_version("Another") | |
| 141 | 126 | $software_category = $env.categories.find_or_create_by_name("Software") |
| 142 | 127 | $software_category.environment = $env |
| 143 | 128 | $software_category.save! |
| ... | ... | @@ -205,6 +190,7 @@ def create_sisp_software_info name, finality = "blank", acronym = "" |
| 205 | 190 | end |
| 206 | 191 | |
| 207 | 192 | software_info = SoftwareInfo.new |
| 193 | + software_info.license_info = $license | |
| 208 | 194 | software_info.community = community |
| 209 | 195 | software_info.finality = finality |
| 210 | 196 | software_info.acronym = acronym | ... | ... |