diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-03-13 15:29:34 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-03-13 15:29:34 +0000 |
commit | d550c46160deb2b9bca12a75f315afdd18cfbdfa (patch) | |
tree | aaebe04473fbbe1fdd332fba29a0ad816c4ea6f5 /app/models | |
parent | 8e3d1b694ab47317638b474082cb70e08a8d02e7 (diff) | |
download | redmine-d550c46160deb2b9bca12a75f315afdd18cfbdfa.tar.gz redmine-d550c46160deb2b9bca12a75f315afdd18cfbdfa.zip |
Makes subtasks rescheduled when a 'precedes' relation is set on a parent task.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3574 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/issue.rb | 19 | ||||
-rw-r--r-- | app/models/issue_relation.rb | 5 |
2 files changed, 20 insertions, 4 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index c39c9ce8f..6eca869d2 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -431,7 +431,24 @@ class Issue < ActiveRecord::Base end def soonest_start - @soonest_start ||= relations_to.collect{|relation| relation.successor_soonest_start}.compact.min + @soonest_start ||= ( + relations_to.collect{|relation| relation.successor_soonest_start} + + ancestors.collect(&:soonest_start) + ).compact.max + end + + def reschedule_after(date) + return if date.nil? + if leaf? + if start_date.nil? || start_date < date + self.start_date, self.due_date = date, date + duration + save + end + else + leaves.each do |leaf| + leaf.reschedule_after(date) + end + end end def <=>(issue) diff --git a/app/models/issue_relation.rb b/app/models/issue_relation.rb index 2c110a72f..a28175d48 100644 --- a/app/models/issue_relation.rb +++ b/app/models/issue_relation.rb @@ -73,9 +73,8 @@ class IssueRelation < ActiveRecord::Base def set_issue_to_dates soonest_start = self.successor_soonest_start - if soonest_start && (!issue_to.start_date || issue_to.start_date < soonest_start) - issue_to.start_date, issue_to.due_date = successor_soonest_start, successor_soonest_start + issue_to.duration - issue_to.save + if soonest_start + issue_to.reschedule_after(soonest_start) end end |