Mercurial > hg > soundsoftware-site
changeset 1258:f8c5708a6fd6 redmine-2.2-integration
Fixed the tag+text queries using scopes.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Wed, 10 Apr 2013 16:53:44 +0100 |
parents | 5bafe0f91f6e |
children | 94a6e3687c45 |
files | plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb |
diffstat | 1 files changed, 19 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb Wed Apr 10 11:57:46 2013 +0100 +++ b/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb Wed Apr 10 16:53:44 2013 +0100 @@ -103,28 +103,26 @@ def filter_projects # find projects like question @question = (params[:search] || "").strip -# - # if params.has_key?(:project) - # @tag_list = (params[:project][:tag_list] || "").strip.split(",") - # else - # @tag_list = [] - # end -# - # if @question == "" - # @projects = Project.visible_roots - # else - # @projects = Project.visible_roots.find(Project.visible.like(@question)) - # end -# - # unless @tag_list.empty? - # @tagged_projects_ids = Project.visible.tagged_with(@tag_list).collect{ |# project| Project.find(project.id).root } -# - # @projects = @projects & @tagged_projects_ids - # @projects = @projects.uniq - # end - # hack... - @projects = Project.like(@question) + if @question.empty? + projects = Project.visible + else + projects = Project.visible.like(@question) + end + + # search for tags + if params.has_key?(:project) + tag_list = (params[:project][:tag_list] || "").strip.split(",") + else + tag_list = "" + end + + unless tag_list.empty? + projects = projects.tagged_with(tag_list) + end + + ## TODO: luisf-10Apr2013 should I only return the visible_roots? + @projects = projects end end