Added project filter when viewing all issues. #5084

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3927 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Baptiste Barth 2010-08-08 09:01:25 +00:00
parent bc5d32d6de
commit 56a6d86af5
2 changed files with 15 additions and 0 deletions

View File

@ -219,6 +219,12 @@ class Query < ActiveRecord::Base
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => system_shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
end
add_custom_fields_filters(IssueCustomField.find(:all, :conditions => {:is_filter => true, :is_for_all => true}))
# project filter
project_values = Project.all(:conditions => Project.visible_by(User.current), :order => 'lft').map do |p|
pre = (p.level > 0 ? ('--' * p.level + ' ') : '')
["#{pre}#{p.name}",p.id.to_s]
end
@available_filters["project_id"] = { :type => :list, :order => 1, :values => project_values}
end
@available_filters
end

View File

@ -33,6 +33,15 @@ class QueryTest < ActiveSupport::TestCase
assert query.available_filters['fixed_version_id'][:values].detect {|v| v.last == '2'}
end
def test_project_filter_in_global_queries
query = Query.new(:project => nil, :name => '_')
project_filter = query.available_filters["project_id"]
assert_not_nil project_filter
project_ids = project_filter[:values].map{|p| p[1]}
assert project_ids.include?("1") #public project
assert !project_ids.include?("2") #private project user cannot see
end
def find_issues_with_query(query)
Issue.find :all,
:include => [ :assigned_to, :status, :tracker, :project, :priority ],