Project

General

Profile

Defect #17580 ยป 17580-RM-3.1.1.patch

Olivier Houdas, 2015-10-20 17:21

View differences:

app/controllers/issues_controller.rb Sun Sep 20 06:20:40 2015 +0000 โ†’ app/controllers/issues_controller.rb Tue Oct 20 17:14:24 2015 +0200
unless User.current.allowed_to?(:copy_issues, @copy_from.project)
raise ::Unauthorized
end
@link_copy = link_copy?(params[:link_copy]) || request.get?
@link_copy = link_copy?(params[:link_copy])
@copy_attachments = params[:copy_attachments].present? || request.get?
@copy_subtasks = params[:copy_subtasks].present? || request.get?
@issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
app/models/issue.rb Sun Sep 20 06:20:40 2015 +0000 โ†’ app/models/issue.rb Tue Oct 20 17:14:33 2015 +0200
# Copies attributes from another issue, arg can be an id or an Issue
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.attributes = issue.attributes.dup.except("id", "root_id", options[:link]? "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
app/models/issue_relation.rb Sun Sep 20 06:20:40 2015 +0000 โ†’ app/models/issue_relation.rb Tue Oct 20 17:14:39 2015 +0200
def validate_issue_relation
if issue_from && issue_to
errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
if issue_to.parent_id && issue_from.parent_id
errors.add :issue_to_id, :invalid if issue_from.parent_id == issue_to.parent_id
end
unless issue_from.project_id == issue_to.project_id ||
Setting.cross_project_issue_relations?
errors.add :issue_to_id, :not_same_project
    (1-1/1)