summaryrefslogtreecommitdiffstats
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-03-13 14:56:49 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-03-13 14:56:49 +0000
commit8e3d1b694ab47317638b474082cb70e08a8d02e7 (patch)
tree9997cc24910a029fea3e98ed0765566d9c4bb97e /app/models/project.rb
parente109c9b6b6f314dea19bf92dffa217d962eaa200 (diff)
downloadredmine-8e3d1b694ab47317638b474082cb70e08a8d02e7.tar.gz
redmine-8e3d1b694ab47317638b474082cb70e08a8d02e7.zip
Adds subtasking (#443) including:
* priority, start/due dates, progress, estimate, spent time roll-up to parent issues * descendant issues tree displayed on the issue view with context menu support * issue tree display on the gantt chart * issue tree copy on project copy * unlimited nesting Defining subtasks requires the new permission 'Manage subtasks'. Subtasks can not belong to a different project than the parent task. Implementation is based on scoped nested sets for fast reads and updates. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3573 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index d5941e095..8d6303224 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -557,9 +557,12 @@ class Project < ActiveRecord::Base
# value. Used to map the two togeather for issue relations.
issues_map = {}
- project.issues.each do |issue|
+ # Get issues sorted by root_id, lft so that parent issues
+ # get copied before their children
+ project.issues.find(:all, :order => 'root_id, lft').each do |issue|
new_issue = Issue.new
new_issue.copy_from(issue)
+ new_issue.project = self
# Reassign fixed_versions by name, since names are unique per
# project and the versions for self are not yet saved
if issue.fixed_version
@@ -570,6 +573,13 @@ class Project < ActiveRecord::Base
if issue.category
new_issue.category = self.issue_categories.select {|c| c.name == issue.category.name}.first
end
+ # Parent issue
+ if issue.parent_id
+ if copied_parent = issues_map[issue.parent_id]
+ new_issue.parent_issue_id = copied_parent.id
+ end
+ end
+
self.issues << new_issue
issues_map[issue.id] = new_issue
end