Commit f34a30e2dab66c50905493371bdb9f028b5e39e5

Authored by Luciano Prestes
1 parent 3176600f

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>
src/noosfero-spb/software_communities/lib/tasks/import_sisp_software.rake
... ... @@ -46,6 +46,8 @@ namespace :software do
46 46 sw.save!
47 47 print '.'
48 48 else
  49 + sw.community.destroy
  50 + sw.destroy
49 51 puts sw.errors.full_messages
50 52 print 'F'
51 53 end
... ... @@ -79,6 +81,11 @@ end
79 81  
80 82 def create_software_info name, finality = "blank", acronym = ""
81 83 community = create_community(name)
  84 +
  85 + if community.software?
  86 + return community.software_info
  87 + end
  88 +
82 89 software_info = SoftwareInfo.new
83 90 software_info.community = community
84 91 software_info.finality = finality
... ... @@ -90,7 +97,7 @@ end
90 97 def set_software_category software, category_name
91 98 category = Category.find_by_name(category_name)
92 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 101 end
95 102  
96 103 def set_sisp_hashes software, sisp_hash
... ...