Commit f34a30e2dab66c50905493371bdb9f028b5e39e5
1 parent
3176600f
Exists in
sisp_simple_version
Remove duplications on import_sisp_software task
Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com> Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Showing
1 changed file
with
8 additions
and
1 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake
@@ -46,6 +46,8 @@ namespace :software do | @@ -46,6 +46,8 @@ namespace :software do | ||
46 | sw.save! | 46 | sw.save! |
47 | print '.' | 47 | print '.' |
48 | else | 48 | else |
49 | + sw.community.destroy | ||
50 | + sw.destroy | ||
49 | puts sw.errors.full_messages | 51 | puts sw.errors.full_messages |
50 | print 'F' | 52 | print 'F' |
51 | end | 53 | end |
@@ -79,6 +81,11 @@ end | @@ -79,6 +81,11 @@ end | ||
79 | 81 | ||
80 | def create_software_info name, finality = "blank", acronym = "" | 82 | def create_software_info name, finality = "blank", acronym = "" |
81 | community = create_community(name) | 83 | community = create_community(name) |
84 | + | ||
85 | + if community.software? | ||
86 | + return community.software_info | ||
87 | + end | ||
88 | + | ||
82 | software_info = SoftwareInfo.new | 89 | software_info = SoftwareInfo.new |
83 | software_info.community = community | 90 | software_info.community = community |
84 | software_info.finality = finality | 91 | software_info.finality = finality |
@@ -90,7 +97,7 @@ end | @@ -90,7 +97,7 @@ end | ||
90 | def set_software_category software, category_name | 97 | def set_software_category software, category_name |
91 | category = Category.find_by_name(category_name) | 98 | category = Category.find_by_name(category_name) |
92 | category ||= Category.create(:name => category_name, :parent => $software_category, :environment => $env) | 99 | category ||= Category.create(:name => category_name, :parent => $software_category, :environment => $env) |
93 | - software.community.categories << category | 100 | + software.community.categories << category unless software.community.categories.include?(category) |
94 | end | 101 | end |
95 | 102 | ||
96 | def set_sisp_hashes software, sisp_hash | 103 | def set_sisp_hashes software, sisp_hash |