Merge pull request #117 from finnlabs/fix/17318_error_message_on_invalid_parent

Move validation of children to OpenProject core
pull/6827/head
Alex Coles 10 years ago
commit 0ad3774ba3
  1. 14
      lib/open_project/backlogs/patches/work_package_patch.rb

@ -68,8 +68,6 @@ module OpenProject::Backlogs::Patches::WorkPackagePatch
validates_each :parent_id do |record, attr, value|
validate_parent_work_package_relation(record, attr, value)
validate_children(record, attr, value) #not using validates_associated because the errors are not displayed nicely then
end
include OpenProject::Backlogs::List
@ -112,18 +110,6 @@ module OpenProject::Backlogs::Patches::WorkPackagePatch
def parent_work_package_relationship_spanning_projects?(parent, child)
child.is_task? && parent.in_backlogs_type? && parent.project_id != child.project_id
end
def validate_children(work_package, attr, value)
if work_package.in_backlogs_type?
work_package.children.each do |child|
unless child.valid?
child.errors.each do |key, value|
work_package.errors.add(:children, value)
end
end
end
end
end
end
module InstanceMethods

Loading…
Cancel
Save