Adds "my projects" filter on the cross-project issue list.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8637 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1054237d82
commit
919d0a68c3
|
@ -240,6 +240,9 @@ class Query < ActiveRecord::Base
|
|||
|
||||
# project filter
|
||||
project_values = []
|
||||
if User.current.logged? && User.current.memberships.any?
|
||||
project_values << ["<< #{l(:label_my_projects).downcase} >>", "mine"]
|
||||
end
|
||||
Project.project_tree(all_projects) do |p, level|
|
||||
prefix = (level > 0 ? ('--' * level + ' ') : '')
|
||||
project_values << ["#{prefix}#{p.name}", p.id.to_s]
|
||||
|
@ -522,6 +525,12 @@ class Query < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
if field == 'project_id'
|
||||
if v.delete('mine')
|
||||
v += User.current.memberships.map(&:project_id).map(&:to_s)
|
||||
end
|
||||
end
|
||||
|
||||
if field =~ /^cf_(\d+)$/
|
||||
# custom field
|
||||
filters_clauses << sql_for_custom_field(field, operator, v, $1)
|
||||
|
|
|
@ -413,6 +413,19 @@ class QueryTest < ActiveSupport::TestCase
|
|||
assert !result.include?(i3)
|
||||
end
|
||||
|
||||
def test_filter_my_projects
|
||||
User.current = User.find(2)
|
||||
query = Query.new(:name => '_')
|
||||
filter = query.available_filters['project_id']
|
||||
assert_not_nil filter
|
||||
assert_include 'mine', filter[:values].map{|v| v[1]}
|
||||
|
||||
query.filters = { 'project_id' => {:operator => '=', :values => ['mine']}}
|
||||
result = query.issues
|
||||
assert_include "issues.project_id IN ('1','2','5')", query.statement
|
||||
assert_nil result.detect {|issue| !User.current.member_of?(issue.project)}
|
||||
end
|
||||
|
||||
def test_filter_watched_issues
|
||||
User.current = User.find(1)
|
||||
query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}})
|
||||
|
|
Loading…
Reference in New Issue