Adds an option of the copy form to enable/disable attachments copy (#3055).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8677 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-01-20 18:22:43 +00:00
parent 8a3623733f
commit fbf30eec7c
49 changed files with 105 additions and 9 deletions
+5 -3
View File
@@ -129,14 +129,16 @@ class Issue < ActiveRecord::Base
end
# Copies attributes from another issue, arg can be an id or an Issue
def copy_from(arg)
def copy_from(arg, options={})
issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
self.status = issue.status
self.author = User.current
self.attachments = issue.attachments.map do |attachement|
attachement.copy(:container => self)
unless options[:attachments] == false
self.attachments = issue.attachments.map do |attachement|
attachement.copy(:container => self)
end
end
@copied_from = issue
self