diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-02-01 20:07:01 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-02-01 20:07:01 +0000 |
commit | 2808adf99f44d1329b1c12c60ecdb6c4105fca5d (patch) | |
tree | d73a9d0ac58e0af04c8357037eccefad299e3569 /app/models/principal.rb | |
parent | 0154d7477b536387b7e50c441e6931027a596dd1 (diff) | |
download | redmine-2808adf99f44d1329b1c12c60ecdb6c4105fca5d.tar.gz redmine-2808adf99f44d1329b1c12c60ecdb6c4105fca5d.zip |
Adds members of subprojects in assignee and author filters (#10126).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8747 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/principal.rb')
-rw-r--r-- | app/models/principal.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/principal.rb b/app/models/principal.rb index d7814f595..77fe19fe0 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -33,6 +33,16 @@ class Principal < ActiveRecord::Base } } + # Principals that are members of a collection of projects + named_scope :member_of, lambda {|projects| + if projects.empty? + {:conditions => "1=0"} + else + ids = projects.map(&:id) + {:conditions => ["#{Principal.table_name}.status = 1 AND #{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids]} + end + } + before_create :set_default_empty_values def name(formatter = nil) |