changeset 786:ae82810661da feature_14

Fixes bug related to returning results with non root projects.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Fri, 18 Nov 2011 16:53:19 +0000
parents b153713dc4fd
children a36cce722860
files vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb	Fri Nov 18 16:04:59 2011 +0000
+++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb	Fri Nov 18 16:53:19 2011 +0000
@@ -76,6 +76,7 @@
           respond_to do |format|
             format.html { 
               paginate_projects
+              
               @projects = Project.visible_roots.find(@projects, :offset => @offset, :limit => @limit, :order => sort_clause) 
 
               if User.current.logged?
@@ -116,14 +117,20 @@
             @tag_list = []
           end
 
-          @projects = Project.visible
+          if  @question == ""
+            @projects = Project.visible
+          else
+            @projects = Project.visible.search_by_question(@question)
+          end
+  
+          unless @tag_list.empty?
+            @tagged_projects_ids = Project.visible.tagged_with(@tag_list).collect{ |project| Project.find(project.id) }
+            @projects = @projects & @tagged_projects_ids
+          end
+          
+          @projects = @projects.collect{ |project| project.root }
+          @projects = @projects.uniq
 
-          # luisf 
-          @projects = @projects.search_by_question(@question) unless @question == ""
-          @tagged_projects_ids = Project.tagged_with(@tag_list).collect{ |project| Project.find(project.id) } unless @tag_list.empty?
-
-          # intersection of both prject groups            
-          @projects = @projects & @tagged_projects_ids unless @tag_list.empty?
         end
       end
     end