|
|
|
@ -161,9 +161,12 @@ module DemoData |
|
|
|
|
|
|
|
|
|
def create_relations(attributes) |
|
|
|
|
Array(attributes[:relations]).each do |relation| |
|
|
|
|
root_work_package = WorkPackage.find_by!(subject: attributes[:subject]) |
|
|
|
|
to_work_package = WorkPackage.find_by(subject: relation[:to], project: root_work_package.project) |
|
|
|
|
to_work_package = WorkPackage.find_by!(subject: relation[:to]) unless to_work_package.nil? |
|
|
|
|
create_relation( |
|
|
|
|
to: WorkPackage.find_by!(subject: relation[:to]), |
|
|
|
|
from: WorkPackage.find_by!(subject: attributes[:subject]), |
|
|
|
|
to: to_work_package, |
|
|
|
|
from: root_work_package, |
|
|
|
|
type: relation[:type] |
|
|
|
|
) |
|
|
|
|
end |
|
|
|
|