Create role by copy (#9258).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10285 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -67,6 +67,15 @@ class Role < ActiveRecord::Base
|
||||
:in => ISSUES_VISIBILITY_OPTIONS.collect(&:first),
|
||||
:if => lambda {|role| role.respond_to?(:issues_visibility)}
|
||||
|
||||
# Copies attributes from another role, arg can be an id or a Role
|
||||
def copy_from(arg, options={})
|
||||
return unless arg.present?
|
||||
role = arg.is_a?(Role) ? arg : Role.find_by_id(arg.to_s)
|
||||
self.attributes = role.attributes.dup.except("id", "name", "position", "builtin", "permissions")
|
||||
self.permissions = role.permissions.dup
|
||||
self
|
||||
end
|
||||
|
||||
def permissions=(perms)
|
||||
perms = perms.collect {|p| p.to_sym unless p.blank? }.compact.uniq if perms
|
||||
write_attribute(:permissions, perms)
|
||||
|
||||
Reference in New Issue
Block a user