Validate WP children

Originially, this method was defined in a WP patch in OpenProject Backlogs.
pull/2315/head
Hagen Schink 10 years ago
parent 8180b6682e
commit 60eb70b30e
  1. 10
      app/models/work_package/validations.rb

@ -52,6 +52,8 @@ module WorkPackage::Validations
validate :validate_status_transition validate :validate_status_transition
validate :validate_active_priority validate :validate_active_priority
validate :validate_children
end end
def validate_start_date_before_soonest_start_date def validate_start_date_before_soonest_start_date
@ -103,6 +105,14 @@ module WorkPackage::Validations
end end
end end
def validate_children
children.select { |c| !c.valid? }.each do |child|
child.errors.each do |_, value|
errors.add(:"##{child.id}", value)
end
end
end
private private
def status_changed? def status_changed?

Loading…
Cancel
Save