##// END OF EJS Templates
remove trailing white-spaces from app/models/group.rb....
Toshi MARUYAMA -
r6722:ce24f4fb89a7
parent child
Show More
@@ -5,12 +5,12
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -18,21 +18,21
18 18 class Group < Principal
19 19 has_and_belongs_to_many :users, :after_add => :user_added,
20 20 :after_remove => :user_removed
21
21
22 22 acts_as_customizable
23
23
24 24 validates_presence_of :lastname
25 25 validates_uniqueness_of :lastname, :case_sensitive => false
26 26 validates_length_of :lastname, :maximum => 30
27
27
28 28 before_destroy :remove_references_before_destroy
29
29
30 30 def to_s
31 31 lastname.to_s
32 32 end
33
33
34 34 alias :name :to_s
35
35
36 36 def user_added(user)
37 37 members.each do |member|
38 38 next if member.project.nil?
@@ -43,20 +43,20 class Group < Principal
43 43 user_member.save!
44 44 end
45 45 end
46
46
47 47 def user_removed(user)
48 48 members.each do |member|
49 49 MemberRole.find(:all, :include => :member,
50 50 :conditions => ["#{Member.table_name}.user_id = ? AND #{MemberRole.table_name}.inherited_from IN (?)", user.id, member.member_role_ids]).each(&:destroy)
51 51 end
52 52 end
53
53
54 54 private
55
55
56 56 # Removes references that are not handled by associations
57 57 def remove_references_before_destroy
58 58 return if self.id.nil?
59
59
60 60 Issue.update_all 'assigned_to_id = NULL', ['assigned_to_id = ?', id]
61 61 end
62 62 end
General Comments 0
You need to be logged in to leave comments. Login now