Project

General

Profile

Defect #7023 » issue.rb.1.1.0.copy_children.patch

patch to merge John S's issue.rb into 1.1.0 branch - Daniel Reiche, 2011-01-19 16:46

View differences:

app/models/issue.rb (working copy)
177 177
          end
178 178
        end
179 179
      end
180
      #Copy Function Changes to support copying subtasks with parent tasks. (Call the copy_children Function)
181
      if options[:copy]
182
        copy_children(self, issue.id, new_project)
183
      end
184
      #End Changes
180 185
    else
181 186
      return false
182 187
    end
......
878 883
                                              group by s.id, s.is_closed, j.id")
879 884
  end
880 885
  
886
  #Copy_Children Function to support copying subtasks with parent tasks.
887
  def copy_children(issue, parent_issue_id, new_project)
888
    issue.children.each do |childissue|
889
      child_issue = Issue.new
890
      child_issue.copy_from(childissue)
891
      child_issue.parent_issue_id = parent_issue_id
892

  
893
      child_issue.project = new_project
894
      if child_issue.save
895
        unless childissue.copy_children(childissue, child_issue.id,new_project)
896
          # Move failed and transaction was rollback'd
897
          return false
898
        end
899
      else
900
        logger.error "failed to save child issue"
901
      end
902
    end
903
  end
904
  #End New Copy Function
905

  
881 906

  
882 907
end
(2-2/3)