Mercurial > hg > soundsoftware-site
diff app/models/principal.rb @ 929:5f33065ddc4b redmine-1.3
Update to Redmine SVN rev 9414 on 1.3-stable branch
author | Chris Cannam |
---|---|
date | Wed, 27 Jun 2012 14:54:18 +0100 |
parents | cbb26bc654de |
children | 433d4f72a19b |
line wrap: on
line diff
--- a/app/models/principal.rb Fri Feb 24 19:09:32 2012 +0000 +++ b/app/models/principal.rb Wed Jun 27 14:54:18 2012 +0100 @@ -32,6 +32,16 @@ :order => 'type, login, lastname, firstname, mail' } } + # Principals that are not members of projects + named_scope :not_member_of, lambda {|projects| + projects = [projects] unless projects.is_a?(Array) + if projects.empty? + {:conditions => "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]} + end + } before_create :set_default_empty_values @@ -40,7 +50,9 @@ end def <=>(principal) - if self.class.name == principal.class.name + if principal.nil? + -1 + elsif self.class.name == principal.class.name self.to_s.downcase <=> principal.to_s.downcase else # groups after users