Commit 0f14fca1b3ae3d97a651936a8d24dbb1f1e10907

Authored by Rodrigo Souto
1 parent 36b2b195

adjust category extension

src/noosfero-spb/software_communities/lib/ext/category.rb
@@ -18,6 +18,8 @@ class Category @@ -18,6 +18,8 @@ class Category
18 _('Transportation and Transit') 18 _('Transportation and Transit')
19 ] 19 ]
20 20
  21 + has_many :softwares, :through => :profile_categorizations, :source => :profile, :class_name => 'Software'
  22 +
21 scope :software_categories, lambda { 23 scope :software_categories, lambda {
22 software_category = Category.find_by_name("Software") 24 software_category = Category.find_by_name("Software")
23 if software_category.nil? 25 if software_category.nil?
@@ -26,10 +28,4 @@ class Category @@ -26,10 +28,4 @@ class Category
26 software_category.children 28 software_category.children
27 end 29 end
28 } 30 }
29 -  
30 - def software_infos  
31 - software_list = self.communities  
32 - software_list.collect { |x| software_list.delete(x) unless x.software? }  
33 - software_list  
34 - end  
35 end 31 end
src/noosfero-spb/software_communities/views/blocks/categories_software.html.erb
@@ -9,8 +9,8 @@ @@ -9,8 +9,8 @@
9 <ul class="categories-mais-software"> 9 <ul class="categories-mais-software">
10 10
11 <% categories.each do |category| %> 11 <% categories.each do |category| %>
12 - <% unless category.software_infos.count < 1 %>  
13 - <li><%= link_to _("#{category.name}") + " (#{category.software_infos.count})", {:controller => :search, :action => :software_infos, :selected_categories_id => [category.id]} %></li> 12 + <% unless category.softwares.count < 1 %>
  13 + <li><%= link_to _("#{category.name}") + " (#{category.softwares.count})", {:controller => :search, :action => :software_infos, :selected_categories_id => [category.id]} %></li>
14 <% end %> 14 <% end %>
15 <% end %> 15 <% end %>
16 </ul> 16 </ul>