Mercurial > hg > soundsoftware-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
909:cbb26bc654de | 929:5f33065ddc4b |
---|---|
30 s = "%#{q.to_s.strip.downcase}%" | 30 s = "%#{q.to_s.strip.downcase}%" |
31 {:conditions => ["LOWER(login) LIKE :s OR LOWER(firstname) LIKE :s OR LOWER(lastname) LIKE :s OR LOWER(mail) LIKE :s", {:s => s}], | 31 {:conditions => ["LOWER(login) LIKE :s OR LOWER(firstname) LIKE :s OR LOWER(lastname) LIKE :s OR LOWER(mail) LIKE :s", {:s => s}], |
32 :order => 'type, login, lastname, firstname, mail' | 32 :order => 'type, login, lastname, firstname, mail' |
33 } | 33 } |
34 } | 34 } |
35 # Principals that are not members of projects | |
36 named_scope :not_member_of, lambda {|projects| | |
37 projects = [projects] unless projects.is_a?(Array) | |
38 if projects.empty? | |
39 {:conditions => "1=0"} | |
40 else | |
41 ids = projects.map(&:id) | |
42 {:conditions => ["#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids]} | |
43 end | |
44 } | |
35 | 45 |
36 before_create :set_default_empty_values | 46 before_create :set_default_empty_values |
37 | 47 |
38 def name(formatter = nil) | 48 def name(formatter = nil) |
39 to_s | 49 to_s |
40 end | 50 end |
41 | 51 |
42 def <=>(principal) | 52 def <=>(principal) |
43 if self.class.name == principal.class.name | 53 if principal.nil? |
54 -1 | |
55 elsif self.class.name == principal.class.name | |
44 self.to_s.downcase <=> principal.to_s.downcase | 56 self.to_s.downcase <=> principal.to_s.downcase |
45 else | 57 else |
46 # groups after users | 58 # groups after users |
47 principal.class.name <=> self.class.name | 59 principal.class.name <=> self.class.name |
48 end | 60 end |