if request.post? && @role.save
# workflow copy
if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
- @role.workflow_rules.copy(copy_from)
+ @role.copy_workflow_rules(copy_from)
end
flash[:notice] = l(:notice_successful_create)
redirect_to roles_path
if @tracker.save
# workflow copy
if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
- @tracker.workflow_rules.copy(copy_from)
+ @tracker.copy_workflow_rules(copy_from)
end
flash[:notice] = l(:notice_successful_create)
redirect_to trackers_path
before_destroy :check_deletable
has_many :workflow_rules, :dependent => :delete_all do
def copy(source_role)
- WorkflowRule.copy(nil, source_role, nil, proxy_association.owner)
+ ActiveSupport::Deprecation.warn "role.workflow_rules.copy is deprecated and will be removed in Redmine 4.0, use role.copy_worflow_rules instead"
+ proxy_association.owner.copy_workflow_rules(source_role)
end
end
has_and_belongs_to_many :custom_fields, :join_table => "#{table_name_prefix}custom_fields_roles#{table_name_suffix}", :foreign_key => "role_id"
self
end
+ def copy_workflow_rules(source_role)
+ WorkflowRule.copy(nil, source_role, nil, self)
+ end
+
# Find all the roles that can be given to a project member
def self.find_all_givable
Role.givable.to_a
has_many :issues
has_many :workflow_rules, :dependent => :delete_all do
def copy(source_tracker)
- WorkflowRule.copy(source_tracker, nil, proxy_association.owner, nil)
+ ActiveSupport::Deprecation.warn "tracker.workflow_rules.copy is deprecated and will be removed in Redmine 4.0, use tracker.copy_worflow_rules instead"
+ proxy_association.owner.copy_workflow_rules(source_tracker)
end
end
-
has_and_belongs_to_many :projects
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
acts_as_positioned
core_fields
end
+ def copy_workflow_rules(source_tracker)
+ WorkflowRule.copy(source_tracker, nil, self, nil)
+ end
+
# Returns the fields that are disabled for all the given trackers
def self.disabled_core_fields(trackers)
if trackers.present?
# Copies workflows from source to targets
def self.copy(source_tracker, source_role, target_trackers, target_roles)
unless source_tracker.is_a?(Tracker) || source_role.is_a?(Role)
- raise ArgumentError.new("source_tracker or source_role must be specified")
+ raise ArgumentError.new("source_tracker or source_role must be specified, given: #{source_tracker.class.name} and #{source_role.class.name}")
end
target_trackers = [target_trackers].flatten.compact
target = Role.new(:name => 'Target')
assert target.save
- target.workflow_rules.copy(source)
+ target.copy_workflow_rules(source)
target.reload
assert_equal rule_count, target.workflow_rules.size
end
target = Tracker.new(:name => 'Target', :default_status_id => 1)
assert target.save
- target.workflow_rules.copy(source)
+ target.copy_workflow_rules(source)
target.reload
assert_equal rules_count, target.workflow_rules.size
end