17580-RM-3.1.1.patch

Olivier Houdas, 2015-10-20 17:21

Download (2.17 KB)

View differences:

app/controllers/issues_controller.rb Tue Oct 20 17:14:24 2015 +0200
411 411
        unless User.current.allowed_to?(:copy_issues, @copy_from.project)
412 412
          raise ::Unauthorized
413 413
        end
414
        @link_copy = link_copy?(params[:link_copy]) || request.get?
414
        @link_copy = link_copy?(params[:link_copy])
415 415
        @copy_attachments = params[:copy_attachments].present? || request.get?
416 416
        @copy_subtasks = params[:copy_subtasks].present? || request.get?
417 417
        @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
app/models/issue.rb Tue Oct 20 17:14:33 2015 +0200
226 226
  # Copies attributes from another issue, arg can be an id or an Issue
227 227
  def copy_from(arg, options={})
228 228
    issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
229
    self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
229
    self.attributes = issue.attributes.dup.except("id", "root_id", options[:link]? "parent_id" : "", "lft", "rgt", "created_on", "updated_on")
230 230
    self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
231 231
    self.status = issue.status
232 232
    self.author = User.current
app/models/issue_relation.rb Tue Oct 20 17:14:39 2015 +0200
97 97
  def validate_issue_relation
98 98
    if issue_from && issue_to
99 99
      errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
100
      if issue_to.parent_id && issue_from.parent_id
101
        errors.add :issue_to_id, :invalid if issue_from.parent_id == issue_to.parent_id
102
      end
100 103
      unless issue_from.project_id == issue_to.project_id ||
101 104
                Setting.cross_project_issue_relations?
102 105
        errors.add :issue_to_id, :not_same_project