summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-10-29 10:06:30 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-10-29 10:06:30 +0000
commitb71355f10b247f35a32fc002d52a9ca536537998 (patch)
tree02618fb61aedd65e713ae699915b39391dd09f79 /app
parent48d83884c36fae4882061360da25f4e2ed1def13 (diff)
downloadredmine-b71355f10b247f35a32fc002d52a9ca536537998.tar.gz
redmine-b71355f10b247f35a32fc002d52a9ca536537998.zip
Ignore non-working days when rescheduling an issue (#2161).
Weekly non-working days can be configured in application settings (set to saturday and sunday by default). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10747 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/settings_helper.rb2
-rw-r--r--app/models/issue.rb25
-rw-r--r--app/models/issue_relation.rb2
-rw-r--r--app/views/settings/_issues.html.erb2
4 files changed, 25 insertions, 6 deletions
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index c1fa8ea64..14708344d 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -56,7 +56,7 @@ module SettingsHelper
Setting.send(setting).include?(value),
:id => nil
) + text.to_s,
- :class => 'block'
+ :class => (options[:inline] ? 'inline' : 'block')
)
end.join.html_safe
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index a2ba73d04..119d688c7 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -17,6 +17,7 @@
class Issue < ActiveRecord::Base
include Redmine::SafeAttributes
+ include Redmine::Utils::DateCalculation
belongs_to :project
belongs_to :tracker
@@ -863,6 +864,11 @@ class Issue < ActiveRecord::Base
(start_date && due_date) ? due_date - start_date : 0
end
+ # Returns the duration in working days
+ def working_duration
+ (start_date && due_date) ? working_days(start_date, due_date) : 0
+ end
+
def soonest_start
@soonest_start ||= (
relations_to.collect{|relation| relation.successor_soonest_start} +
@@ -870,22 +876,33 @@ class Issue < ActiveRecord::Base
).compact.max
end
- def reschedule_after(date)
+ # Sets start_date on the given date or the next working day
+ # and changes due_date to keep the same working duration.
+ def reschedule_on(date)
+ wd = working_duration
+ date = next_working_date(date)
+ self.start_date = date
+ self.due_date = add_working_days(date, wd)
+ end
+
+ # Reschedules the issue on the given date or the next working day and saves the record.
+ # If the issue is a parent task, this is done by rescheduling its subtasks.
+ def reschedule_on!(date)
return if date.nil?
if leaf?
if start_date.nil? || start_date < date
- self.start_date, self.due_date = date, date + duration
+ reschedule_on(date)
begin
save
rescue ActiveRecord::StaleObjectError
reload
- self.start_date, self.due_date = date, date + duration
+ reschedule_on(date)
save
end
end
else
leaves.each do |leaf|
- leaf.reschedule_after(date)
+ leaf.reschedule_on!(date)
end
end
end
diff --git a/app/models/issue_relation.rb b/app/models/issue_relation.rb
index 285c4e306..59b1900f0 100644
--- a/app/models/issue_relation.rb
+++ b/app/models/issue_relation.rb
@@ -135,7 +135,7 @@ class IssueRelation < ActiveRecord::Base
def set_issue_to_dates
soonest_start = self.successor_soonest_start
if soonest_start && issue_to
- issue_to.reschedule_after(soonest_start)
+ issue_to.reschedule_on!(soonest_start)
end
end
diff --git a/app/views/settings/_issues.html.erb b/app/views/settings/_issues.html.erb
index a8d004daa..dcf5df86e 100644
--- a/app/views/settings/_issues.html.erb
+++ b/app/views/settings/_issues.html.erb
@@ -13,6 +13,8 @@
<p><%= setting_select :issue_done_ratio, Issue::DONE_RATIO_OPTIONS.collect {|i| [l("setting_issue_done_ratio_#{i}"), i]} %></p>
+<p><%= setting_multiselect :non_working_week_days, (1..7).map {|d| [day_name(d), d]}, :inline => true %></p>
+
<p><%= setting_text_field :issues_export_limit, :size => 6 %></p>
<p><%= setting_text_field :gantt_items_limit, :size => 6 %></p>