Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10804 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
547b85c4ef
commit
b880020527
|
@ -48,20 +48,20 @@ class Principal < ActiveRecord::Base
|
|||
scope :member_of, lambda {|projects|
|
||||
projects = [projects] unless projects.is_a?(Array)
|
||||
if projects.empty?
|
||||
{:conditions => "1=0"}
|
||||
where("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]}
|
||||
where("#{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
|
||||
}
|
||||
# Principals that are not members of projects
|
||||
scope :not_member_of, lambda {|projects|
|
||||
projects = [projects] unless projects.is_a?(Array)
|
||||
if projects.empty?
|
||||
{:conditions => "1=0"}
|
||||
where("1=0")
|
||||
else
|
||||
ids = projects.map(&:id)
|
||||
{:conditions => ["#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids]}
|
||||
where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids)
|
||||
end
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue