##// END OF EJS Templates
remove trailing white-spaces from app/models/member.rb....
Toshi MARUYAMA -
r6383:67169fe9dd19
parent child
Show More
@@ -1,16 +1,16
1 1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
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.
@@ -26,17 +26,17 class Member < ActiveRecord::Base
26 26 validates_uniqueness_of :user_id, :scope => :project_id
27 27
28 28 after_destroy :unwatch_from_permission_change
29
29
30 30 def name
31 31 self.user.name
32 32 end
33
33
34 34 alias :base_role_ids= :role_ids=
35 35 def role_ids=(arg)
36 36 ids = (arg || []).collect(&:to_i) - [0]
37 37 # Keep inherited roles
38 38 ids += member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)
39
39
40 40 new_role_ids = ids - role_ids
41 41 # Add new roles
42 42 new_role_ids.each {|id| member_roles << MemberRole.new(:role_id => id) }
@@ -47,16 +47,16 class Member < ActiveRecord::Base
47 47 unwatch_from_permission_change
48 48 end
49 49 end
50
50
51 51 def <=>(member)
52 52 a, b = roles.sort.first, member.roles.sort.first
53 53 a == b ? (principal <=> member.principal) : (a <=> b)
54 54 end
55
55
56 56 def deletable?
57 57 member_roles.detect {|mr| mr.inherited_from}.nil?
58 58 end
59
59
60 60 def include?(user)
61 61 if principal.is_a?(Group)
62 62 !user.nil? && user.groups.include?(principal)
@@ -64,7 +64,7 class Member < ActiveRecord::Base
64 64 self.user == user
65 65 end
66 66 end
67
67
68 68 def before_destroy
69 69 if user
70 70 # remove category based auto assignments for this member
@@ -78,15 +78,15 class Member < ActiveRecord::Base
78 78 @membership.attributes = new_attributes
79 79 @membership
80 80 end
81
81
82 82 protected
83
83
84 84 def validate
85 85 errors.add_on_empty :role if member_roles.empty? && roles.empty?
86 86 end
87
87
88 88 private
89
89
90 90 # Unwatch things that the user is no longer allowed to view inside project
91 91 def unwatch_from_permission_change
92 92 if user
General Comments 0
You need to be logged in to leave comments. Login now