Project

General

Profile

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

Revised working patch for issue.rb from 1.1.0 - r4732 - Daniel Reiche, 2011-01-20 09:45

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
183 188
    issue
184 189
  end
185 190

  
191
  #Copy_Children Function to support copying subtasks with parent tasks.
192
  def copy_children(issue, parent_issue_id, new_project)
193
    issue.children.each do |childissue|
194
      child_issue = Issue.new
195
      child_issue.copy_from(childissue)
196
      child_issue.parent_issue_id = parent_issue_id
197
  
198
      child_issue.project = new_project
199
      if child_issue.save
200
        unless childissue.copy_children(childissue, child_issue.id,new_project)
201
          # Move failed and transaction was rollback'd
202
          return false
203
        end
204
      else
205
        logger.error "failed to save child issue"
206
      end
207
    end
208
  end
209
  #End New Copy Function
210
  
186 211
  def status_id=(sid)
187 212
    self.status = nil
188 213
    write_attribute(:status_id, sid)
......
877 902
                                                and i.project_id=#{project.id}
878 903
                                              group by s.id, s.is_closed, j.id")
879 904
  end
880
  
881

  
905
 
882 906
end
(3-3/3)