Use the regular issue form to copy a single issue.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8552 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
+10
-1
@@ -127,12 +127,14 @@ class Issue < ActiveRecord::Base
|
||||
(project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : []
|
||||
end
|
||||
|
||||
# Copies attributes from another issue, arg can be an id or an Issue
|
||||
def copy_from(arg)
|
||||
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
|
||||
@copied_from = issue
|
||||
self
|
||||
end
|
||||
|
||||
@@ -143,6 +145,11 @@ class Issue < ActiveRecord::Base
|
||||
copy
|
||||
end
|
||||
|
||||
# Returns true if the issue is a copy
|
||||
def copy?
|
||||
@copied_from.present?
|
||||
end
|
||||
|
||||
# Moves/copies an issue to a new project and tracker
|
||||
# Returns the moved/copied issue on success, false on failure
|
||||
def move_to_project(new_project, new_tracker=nil, options={})
|
||||
@@ -255,7 +262,9 @@ class Issue < ActiveRecord::Base
|
||||
|
||||
safe_attributes 'project_id',
|
||||
:if => lambda {|issue, user|
|
||||
if user.allowed_to?(:move_issues, issue.project)
|
||||
if issue.new_record?
|
||||
issue.copy?
|
||||
elsif user.allowed_to?(:move_issues, issue.project)
|
||||
projects = Issue.allowed_target_projects_on_move(user)
|
||||
projects.include?(issue.project) && projects.size > 1
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user