remove trailing white-spaces from app/models/member.rb.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6503 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a8c0583e5e
commit
67169fe9dd
@ -1,16 +1,16 @@
|
|||||||
# Redmine - project management software
|
# Redmine - project management software
|
||||||
# Copyright (C) 2006-2009 Jean-Philippe Lang
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -26,17 +26,17 @@ class Member < ActiveRecord::Base
|
|||||||
validates_uniqueness_of :user_id, :scope => :project_id
|
validates_uniqueness_of :user_id, :scope => :project_id
|
||||||
|
|
||||||
after_destroy :unwatch_from_permission_change
|
after_destroy :unwatch_from_permission_change
|
||||||
|
|
||||||
def name
|
def name
|
||||||
self.user.name
|
self.user.name
|
||||||
end
|
end
|
||||||
|
|
||||||
alias :base_role_ids= :role_ids=
|
alias :base_role_ids= :role_ids=
|
||||||
def role_ids=(arg)
|
def role_ids=(arg)
|
||||||
ids = (arg || []).collect(&:to_i) - [0]
|
ids = (arg || []).collect(&:to_i) - [0]
|
||||||
# Keep inherited roles
|
# Keep inherited roles
|
||||||
ids += member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)
|
ids += member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)
|
||||||
|
|
||||||
new_role_ids = ids - role_ids
|
new_role_ids = ids - role_ids
|
||||||
# Add new roles
|
# Add new roles
|
||||||
new_role_ids.each {|id| member_roles << MemberRole.new(:role_id => id) }
|
new_role_ids.each {|id| member_roles << MemberRole.new(:role_id => id) }
|
||||||
@ -47,16 +47,16 @@ class Member < ActiveRecord::Base
|
|||||||
unwatch_from_permission_change
|
unwatch_from_permission_change
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def <=>(member)
|
def <=>(member)
|
||||||
a, b = roles.sort.first, member.roles.sort.first
|
a, b = roles.sort.first, member.roles.sort.first
|
||||||
a == b ? (principal <=> member.principal) : (a <=> b)
|
a == b ? (principal <=> member.principal) : (a <=> b)
|
||||||
end
|
end
|
||||||
|
|
||||||
def deletable?
|
def deletable?
|
||||||
member_roles.detect {|mr| mr.inherited_from}.nil?
|
member_roles.detect {|mr| mr.inherited_from}.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def include?(user)
|
def include?(user)
|
||||||
if principal.is_a?(Group)
|
if principal.is_a?(Group)
|
||||||
!user.nil? && user.groups.include?(principal)
|
!user.nil? && user.groups.include?(principal)
|
||||||
@ -64,7 +64,7 @@ class Member < ActiveRecord::Base
|
|||||||
self.user == user
|
self.user == user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_destroy
|
def before_destroy
|
||||||
if user
|
if user
|
||||||
# remove category based auto assignments for this member
|
# remove category based auto assignments for this member
|
||||||
@ -78,15 +78,15 @@ class Member < ActiveRecord::Base
|
|||||||
@membership.attributes = new_attributes
|
@membership.attributes = new_attributes
|
||||||
@membership
|
@membership
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
errors.add_on_empty :role if member_roles.empty? && roles.empty?
|
errors.add_on_empty :role if member_roles.empty? && roles.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Unwatch things that the user is no longer allowed to view inside project
|
# Unwatch things that the user is no longer allowed to view inside project
|
||||||
def unwatch_from_permission_change
|
def unwatch_from_permission_change
|
||||||
if user
|
if user
|
||||||
|
Loading…
x
Reference in New Issue
Block a user