Commit 72e64ce85a05b34fe093ccd766be44153a37f363

Authored by Luciano Prestes
Committed by Thiago Ribeiro
1 parent f62669cc

Fix for filter_communities on search communities with another plugin

lib/ext/community.rb
... ... @@ -26,6 +26,15 @@ class Community
26 26 community
27 27 end
28 28  
  29 + def self.get_valid_communities_string
  30 + remove_of_communities_methods = Community.instance_methods.select{|m| m =~ /remove_of_community_search/}
  31 + valid_communities_string = ""
  32 + remove_of_communities_methods.each do |method|
  33 + valid_communities_string += "!community.send('#{method}') && "
  34 + end
  35 + valid_communities_string[0..-5]
  36 + end
  37 +
29 38 def software?
30 39 return !software_info.nil?
31 40 end
... ... @@ -39,4 +48,8 @@ class Community
39 48 self.visible = true
40 49 self.save!
41 50 end
  51 +
  52 + def remove_of_community_search_software?
  53 + return software?
  54 + end
42 55 end
... ...
lib/ext/search_controller.rb
... ... @@ -3,12 +3,12 @@ require_dependency 'search_controller'
3 3 class SearchController
4 4  
5 5 def communities
6   - results = filter_communities_list do |community|
7   - !community.software?
8   - end
9   - results = results.paginate(:per_page => 24, :page => params[:page])
10   - @searches[@asset] = {:results => results}
11   - @search = results
  6 + valid_communities_string = Community.get_valid_communities_string
  7 +
  8 + @scope = visible_profiles(Community)
  9 + @scope.each{|community| @scope.delete(community) unless eval(valid_communities_string)}
  10 +
  11 + full_text_search
12 12 end
13 13  
14 14 def software_infos
... ... @@ -162,5 +162,4 @@ class SearchController
162 162 end
163 163 end
164 164 end
165   -
166 165 end
... ...