diff --git a/app/controllers/admin/region_validators_controller.rb b/app/controllers/admin/region_validators_controller.rb index 4388a7f..fe6bcb2 100644 --- a/app/controllers/admin/region_validators_controller.rb +++ b/app/controllers/admin/region_validators_controller.rb @@ -33,7 +33,7 @@ class RegionValidatorsController < AdminController def load_region_and_search @region = environment.regions.find(params[:id]) if params[:search] - @search = @region.search_possible_validators(params[:search]) + @search = find_by_contents(Organization, params[:search])[:results].docs.reject {|item| @region.validator_ids.include?(item.id) } end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7d51312..87715a7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -154,4 +154,9 @@ class ApplicationController < ActionController::Base end end + def find_by_contents(klass, query, paginate_options{}, options={}) + @plugins.first(:find_by_contents, klass, query, paginate_options, options) || + # Failback search using like + end + end diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index ccae169..85dba4b 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -270,8 +270,7 @@ class CmsController < MyProfileController def search query = params[:q] - results = profile.files.published.find_by_contents(query)[:results] - # results = @plugins.first(:find_by_contents, profile.files.published, query)[:results] + results = find_by_contents(profile.files.published, query)[:results] render :text => article_list_to_json(results), :content_type => 'application/json' end diff --git a/app/controllers/public/profile_search_controller.rb b/app/controllers/public/profile_search_controller.rb index dd7b70f..f6bc0f8 100644 --- a/app/controllers/public/profile_search_controller.rb +++ b/app/controllers/public/profile_search_controller.rb @@ -11,7 +11,7 @@ class ProfileSearchController < PublicController if params[:where] == 'environment' redirect_to :controller => 'search', :query => @q else - @results = @plugins.first(:find_by_contents, profile.articles.published, @q, {:per_page => 10, :page => params[:page]})[:results] + @results = find_by_contents(profile.articles.published, @q, {:per_page => 10, :page => params[:page]})[:results] end end end diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb index dc086c5..b0a0e0f 100644 --- a/app/controllers/public/search_controller.rb +++ b/app/controllers/public/search_controller.rb @@ -8,7 +8,6 @@ class SearchController < PublicController before_filter :load_category before_filter :load_search_assets before_filter :load_query - before_filter :load_search_engine # Backwards compatibility with old URLs def redirect_asset_param @@ -58,7 +57,7 @@ class SearchController < PublicController end def articles - if @search_engine && !@empty_query + if !@empty_query full_text_search else @searches[@asset] = {} @@ -71,7 +70,7 @@ class SearchController < PublicController end def people - if @search_engine && !@empty_query + if !@empty_query full_text_search else @searches[@asset] = {} @@ -80,7 +79,7 @@ class SearchController < PublicController end def products - if @search_engine + if !@empty_query full_text_search else @searches[@asset] = {} @@ -89,7 +88,7 @@ class SearchController < PublicController end def enterprises - if @search_engine && !@empty_query + if !@empty_query full_text_search else @filter_title = _('Enterprises from network') @@ -99,7 +98,7 @@ class SearchController < PublicController end def communities - if @search_engine && !@empty_query + if !@empty_query full_text_search else @searches[@asset] = {} @@ -123,7 +122,7 @@ class SearchController < PublicController environment.events.by_day(@selected_day) end - if @search_engine && !@empty_query + if !@empty_query full_text_search else @searches[@asset] = {} @@ -192,10 +191,6 @@ class SearchController < PublicController end end - def load_search_engine - @search_engine = @plugins.first_plugin(:search_engine?) - end - FILTERS = %w( more_recent more_active @@ -261,7 +256,7 @@ class SearchController < PublicController end def full_text_search - @searches[@asset] = @plugins.first(:find_by_contents, asset_class(@asset), @query, paginate_options(params[:page]), {:category => @category}) + @searches[@asset] = find_by_contents(asset_class(@asset), @query, paginate_options(params[:page]), {:category => @category}) end private diff --git a/app/models/region.rb b/app/models/region.rb index 6e807d8..4aad293 100644 --- a/app/models/region.rb +++ b/app/models/region.rb @@ -4,14 +4,6 @@ class Region < Category require_dependency 'enterprise' # enterprises can also be validators - include Noosfero::Plugin::HotSpot - - # searches for organizations that could become validators for this region. - # search is passed as is to find_by_contents on Organization. - def search_possible_validators(search) - plugins.find_by_contents(Organization, search)[:results].docs.reject {|item| self.validator_ids.include?(item.id) } - end - def has_validator? validators.count > 0 end diff --git a/app/views/layouts/application-ng.rhtml b/app/views/layouts/application-ng.rhtml index cc96b58..480e3f9 100644 --- a/app/views/layouts/application-ng.rhtml +++ b/app/views/layouts/application-ng.rhtml @@ -69,13 +69,11 @@ <% end %> - <% if @plugins.first(:search_engine?) %> -
- <% end %> +