turn the method into a protected one

pull/4599/head
Jens Ulferts 8 years ago
parent 8b8951d75a
commit 96a56c8e8b
  1. 59
      app/models/work_package.rb

@ -124,7 +124,7 @@ class WorkPackage < ActiveRecord::Base
include OpenProject::NestedSet::WithRootIdScope
after_save :reschedule_following_issues,
after_save :reschedule_following_work_packages,
:update_parent_attributes
after_move :remove_invalid_relations,
@ -369,27 +369,6 @@ class WorkPackage < ActiveRecord::Base
).compact.max
end
# Updates start/due dates of following issues
def reschedule_following_issues
delta = date_rescheduling_delta
if delta < 0
relations_from.each { |r| r.move_target_dates_by(delta) }
elsif start_date_changed? || due_date_changed?
relations_from.each(&:set_dates_of_target)
end
end
def date_rescheduling_delta
if due_date.present?
due_date - (due_date_was || 0)
elsif start_date.present?
start_date - (start_date_was || 0)
else
0
end
end
# Users/groups the work_package can be assigned to
extend Forwardable
def_delegator :project, :possible_assignees, :assignable_assignees
@ -666,6 +645,42 @@ class WorkPackage < ActiveRecord::Base
end
end
# Updates start/due dates of following work packages.
# If
# * there no start/due dates are set
# => no scheduling will happen.
# * a due date is set and the due date is moved backwards
# => following work package is moved backwards as well
# * a due date is set and the due date is moved forward
# => following work package is moved forward to the point that
# the work package is again scheduled to be after this work package.
# If a delay is defined, that delay is adhered to.
# * only a start date is set and the start date is moved backwards
# => following work package is moved backwards as well
# * only a start date is set and the start date is moved forward
# => following work package is moved forward to the point that
# the work package is again scheduled to be after this work package.
# If a delay is defined, that delay is adhered to.
def reschedule_following_work_packages
delta = date_rescheduling_delta
if delta < 0
relations_from.each { |r| r.move_target_dates_by(delta) }
elsif start_date_changed? || due_date_changed?
relations_from.each(&:set_dates_of_target)
end
end
def date_rescheduling_delta
if due_date.present?
due_date - (due_date_was || 0)
elsif start_date.present?
start_date - (start_date_was || 0)
else
0
end
end
def recalculate_attributes_for_former_parent
recalculate_attributes_for(@former_parent_id) if @former_parent_id
end

Loading…
Cancel
Save