Commit 9a9baa5313cfe365e6c6ec326861a6cc0598dc20
1 parent
12f620db
Exists in
master
and in
3 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
@@ -3,8 +3,20 @@ require_dependency 'community' | @@ -3,8 +3,20 @@ require_dependency 'community' | ||
3 | class Community | 3 | class Community |
4 | has_one :institution, :dependent=>:destroy | 4 | has_one :institution, :dependent=>:destroy |
5 | 5 | ||
6 | - | ||
7 | def institution? | 6 | def institution? |
8 | return !institution.nil? | 7 | return !institution.nil? |
9 | end | 8 | end |
9 | + | ||
10 | + def remove_of_community_search_institution? | ||
11 | + return institution? | ||
12 | + end | ||
13 | + | ||
14 | + def self.get_valid_communities_string | ||
15 | + remove_of_communities_methods = Community.instance_methods.select{|m| m =~ /remove_of_community_search/} | ||
16 | + valid_communities_string = "" | ||
17 | + remove_of_communities_methods.each do |method| | ||
18 | + valid_communities_string += "!community.send('#{method}') && " | ||
19 | + end | ||
20 | + valid_communities_string[0..-5] | ||
21 | + end | ||
10 | end | 22 | 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.institution? | ||
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 institutions | 14 | def institutions |