Adds a "Copied from/to" relation when copying issue(s) (#6899).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10491 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
+13
-4
@@ -1011,11 +1011,20 @@ class Issue < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# Copies subtasks from the copied issue
|
||||
# Callback for after the creation of an issue by copy
|
||||
# * adds a "copied to" relation with the copied issue
|
||||
# * copies subtasks from the copied issue
|
||||
def after_create_from_copy
|
||||
return unless copy?
|
||||
return unless copy? && !@after_create_from_copy_handled
|
||||
|
||||
unless @copied_from.leaf? || @copy_options[:subtasks] == false || @subtasks_copied
|
||||
if @copied_from.project_id == project_id || Setting.cross_project_issue_relations?
|
||||
relation = IssueRelation.new(:issue_from => @copied_from, :issue_to => self, :relation_type => IssueRelation::TYPE_COPIED_TO)
|
||||
unless relation.save
|
||||
logger.error "Could not create relation while copying ##{@copied_from.id} to ##{id} due to validation errors: #{relation.errors.full_messages.join(', ')}" if logger
|
||||
end
|
||||
end
|
||||
|
||||
unless @copied_from.leaf? || @copy_options[:subtasks] == false
|
||||
@copied_from.children.each do |child|
|
||||
unless child.visible?
|
||||
# Do not copy subtasks that are not visible to avoid potential disclosure of private data
|
||||
@@ -1031,8 +1040,8 @@ class Issue < ActiveRecord::Base
|
||||
logger.error "Could not copy subtask ##{child.id} while copying ##{@copied_from.id} to ##{id} due to validation errors: #{copy.errors.full_messages.join(', ')}" if logger
|
||||
end
|
||||
end
|
||||
@subtasks_copied = true
|
||||
end
|
||||
@after_create_from_copy_handled = true
|
||||
end
|
||||
|
||||
def update_nested_set_attributes
|
||||
|
||||
Reference in New Issue
Block a user