Commit 61e9587f82714ba36568094c473790562eed4cd3
1 parent
0d6b796f
Exists in
sisp_simple_version
Fix function names on task import_sisp_software
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Showing
2 changed files
with
38 additions
and
34 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/tasks/create_sample_softwares.rake
| 1 | NUMBER_OF_SOFTWARES = 10 | 1 | NUMBER_OF_SOFTWARES = 10 |
| 2 | 2 | ||
| 3 | +def create_community(name) | ||
| 4 | + community = Community.new | ||
| 5 | + community.name = name | ||
| 6 | + community.save | ||
| 7 | + community | ||
| 8 | +end | ||
| 9 | + | ||
| 10 | +def create_software_info(name, acronym = "", finality = "default") | ||
| 11 | + community = create_community(name) | ||
| 12 | + software_info = SoftwareInfo.new | ||
| 13 | + software_info.community = community | ||
| 14 | + software_info.public_software = true | ||
| 15 | + software_info.acronym = acronym | ||
| 16 | + software_info.finality = finality | ||
| 17 | + software_info.license_info = LicenseInfo.first | ||
| 18 | + | ||
| 19 | + if software_info.community.valid? && software_info.valid? | ||
| 20 | + print "." | ||
| 21 | + software_info.save | ||
| 22 | + software_info | ||
| 23 | + else | ||
| 24 | + print "F" | ||
| 25 | + nil | ||
| 26 | + end | ||
| 27 | +end | ||
| 3 | namespace :software do | 28 | namespace :software do |
| 4 | desc "Create sample softwares" | 29 | desc "Create sample softwares" |
| 5 | task :create_sample_softwares => :environment do | 30 | task :create_sample_softwares => :environment do |
| @@ -44,28 +69,3 @@ namespace :software do | @@ -44,28 +69,3 @@ namespace :software do | ||
| 44 | end | 69 | end |
| 45 | end | 70 | end |
| 46 | 71 | ||
| 47 | -def create_community(name) | ||
| 48 | - community = Community.new | ||
| 49 | - community.name = name | ||
| 50 | - community.save | ||
| 51 | - community | ||
| 52 | -end | ||
| 53 | - | ||
| 54 | -def create_software_info(name, acronym = "", finality = "default") | ||
| 55 | - community = create_community(name) | ||
| 56 | - software_info = SoftwareInfo.new | ||
| 57 | - software_info.community = community | ||
| 58 | - software_info.public_software = true | ||
| 59 | - software_info.acronym = acronym | ||
| 60 | - software_info.finality = finality | ||
| 61 | - software_info.license_info = LicenseInfo.first | ||
| 62 | - | ||
| 63 | - if software_info.community.valid? && software_info.valid? | ||
| 64 | - print "." | ||
| 65 | - software_info.save | ||
| 66 | - software_info | ||
| 67 | - else | ||
| 68 | - print "F" | ||
| 69 | - nil | ||
| 70 | - end | ||
| 71 | -end |
src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake
| @@ -3,14 +3,18 @@ | @@ -3,14 +3,18 @@ | ||
| 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.find_by_name("sisp") |
| 7 | + env = Environment.default #TODO change this to correct environment | ||
| 7 | 8 | ||
| 8 | if env.present? | 9 | if env.present? |
| 9 | - template = Community.where(identifier: "software", environment_id: env).last | ||
| 10 | - template ||= Community.create!(name: "Software", identifier: "software", is_template: true, environment: env) | 10 | + template = Community.where(identifier: "sisp-software", environment_id: env).last |
| 11 | 11 | ||
| 12 | - template.boxes.find_by_position(1).blocks << StatisticBlock.new | ||
| 13 | - template.save! | 12 | + unless template |
| 13 | + template ||= Community.create!(name: "Sisp Software", identifier: "sisp-software", is_template: true, environment: env) | ||
| 14 | + | ||
| 15 | + template.boxes.find_by_position(1).blocks << StatisticBlock.new | ||
| 16 | + template.save! | ||
| 17 | + end | ||
| 14 | end | 18 | end |
| 15 | end | 19 | end |
| 16 | 20 | ||
| @@ -58,7 +62,7 @@ namespace :software do | @@ -58,7 +62,7 @@ namespace :software do | ||
| 58 | end | 62 | end |
| 59 | end | 63 | end |
| 60 | 64 | ||
| 61 | -def create_community name | 65 | +def create_sisp_community name |
| 62 | 66 | ||
| 63 | identifier = create_identifier name | 67 | identifier = create_identifier name |
| 64 | 68 | ||
| @@ -79,8 +83,8 @@ def create_community name | @@ -79,8 +83,8 @@ def create_community name | ||
| 79 | community | 83 | community |
| 80 | end | 84 | end |
| 81 | 85 | ||
| 82 | -def create_software_info name, finality = "blank", acronym = "" | ||
| 83 | - community = create_community(name) | 86 | +def create_sisp_software_info name, finality = "blank", acronym = "" |
| 87 | + community = create_sisp_community(name) | ||
| 84 | 88 | ||
| 85 | if community.software? | 89 | if community.software? |
| 86 | return community.software_info | 90 | return community.software_info |
| @@ -204,7 +208,7 @@ def create_software_and_attrs sisp_hash | @@ -204,7 +208,7 @@ def create_software_and_attrs sisp_hash | ||
| 204 | 208 | ||
| 205 | identifier = create_identifier name | 209 | identifier = create_identifier name |
| 206 | 210 | ||
| 207 | - software = create_software_info(name) | 211 | + software = create_sisp_software_info(name) |
| 208 | 212 | ||
| 209 | create_ratings identifier, sisp_hash | 213 | create_ratings identifier, sisp_hash |
| 210 | 214 |