comparison app/models/group.rb @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents 433d4f72a19b
children e248c7af89ec
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
23 23
24 acts_as_customizable 24 acts_as_customizable
25 25
26 validates_presence_of :lastname 26 validates_presence_of :lastname
27 validates_uniqueness_of :lastname, :case_sensitive => false 27 validates_uniqueness_of :lastname, :case_sensitive => false
28 validates_length_of :lastname, :maximum => 30 28 validates_length_of :lastname, :maximum => 255
29 29
30 before_destroy :remove_references_before_destroy 30 before_destroy :remove_references_before_destroy
31 31
32 scope :sorted, order("#{table_name}.lastname ASC") 32 scope :sorted, lambda { order("#{table_name}.lastname ASC") }
33 scope :named, lambda {|arg| where("LOWER(#{table_name}.lastname) = LOWER(?)", arg.to_s.strip)}
33 34
34 safe_attributes 'name', 35 safe_attributes 'name',
35 'user_ids', 36 'user_ids',
36 'custom_field_values', 37 'custom_field_values',
37 'custom_fields', 38 'custom_fields',
60 end 61 end
61 end 62 end
62 63
63 def user_removed(user) 64 def user_removed(user)
64 members.each do |member| 65 members.each do |member|
65 MemberRole.find(:all, :include => :member, 66 MemberRole.
66 :conditions => ["#{Member.table_name}.user_id = ? AND #{MemberRole.table_name}.inherited_from IN (?)", user.id, member.member_role_ids]).each(&:destroy) 67 includes(:member).
68 where("#{Member.table_name}.user_id = ? AND #{MemberRole.table_name}.inherited_from IN (?)", user.id, member.member_role_ids).
69 all.
70 each(&:destroy)
67 end 71 end
68 end 72 end
69 73
70 def self.human_attribute_name(attribute_key_name, *args) 74 def self.human_attribute_name(attribute_key_name, *args)
71 attr_name = attribute_key_name.to_s 75 attr_name = attribute_key_name.to_s