Commit 72e64ce85a05b34fe093ccd766be44153a37f363
Committed by
Thiago Ribeiro
1 parent
f62669cc
Exists in
master
and in
5 other branches
Fix for filter_communities on search communities with another plugin
Showing
2 changed files
with
19 additions
and
7 deletions
Show diff stats
lib/ext/community.rb
@@ -26,6 +26,15 @@ class Community | @@ -26,6 +26,15 @@ class Community | ||
26 | community | 26 | community |
27 | end | 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 | def software? | 38 | def software? |
30 | return !software_info.nil? | 39 | return !software_info.nil? |
31 | end | 40 | end |
@@ -39,4 +48,8 @@ class Community | @@ -39,4 +48,8 @@ class Community | ||
39 | self.visible = true | 48 | self.visible = true |
40 | self.save! | 49 | self.save! |
41 | end | 50 | end |
51 | + | ||
52 | + def remove_of_community_search_software? | ||
53 | + return software? | ||
54 | + end | ||
42 | end | 55 | end |
lib/ext/search_controller.rb
@@ -3,12 +3,12 @@ require_dependency 'search_controller' | @@ -3,12 +3,12 @@ require_dependency 'search_controller' | ||
3 | class SearchController | 3 | class SearchController |
4 | 4 | ||
5 | def communities | 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 | end | 12 | end |
13 | 13 | ||
14 | def software_infos | 14 | def software_infos |
@@ -162,5 +162,4 @@ class SearchController | @@ -162,5 +162,4 @@ class SearchController | ||
162 | end | 162 | end |
163 | end | 163 | end |
164 | end | 164 | end |
165 | - | ||
166 | end | 165 | end |