Commit 0d8a97dc authored by James Lopez's avatar James Lopez

some more fixes to import projects

parent c94c0dc0
...@@ -58,12 +58,21 @@ module Projects ...@@ -58,12 +58,21 @@ module Projects
relation.values.flatten.each do |sub_relation| relation.values.flatten.each do |sub_relation|
relation_hash = relation_item[sub_relation.to_s] relation_hash = relation_item[sub_relation.to_s]
next if relation_hash.blank? next if relation_hash.blank?
sub_relation_object = relation_from_factory(sub_relation, relation_hash) process_sub_relation(relation_hash, relation_item, sub_relation)
relation_item[sub_relation.to_s] = sub_relation_object
end end
end end
end end
def process_sub_relation(relation_hash, relation_item, sub_relation)
sub_relation_object = nil
if relation_hash.is_a?(Array)
sub_relation_object = create_relation(sub_relation, relation_hash)
else
sub_relation_object = relation_from_factory(sub_relation, relation_hash)
end
relation_item[sub_relation.to_s] = sub_relation_object
end
def create_relation(relation, relation_hash_list) def create_relation(relation, relation_hash_list)
[relation_hash_list].flatten.map do |relation_hash| [relation_hash_list].flatten.map do |relation_hash|
relation_from_factory(relation, relation_hash) relation_from_factory(relation, relation_hash)
......
...@@ -48,8 +48,8 @@ module Projects ...@@ -48,8 +48,8 @@ module Projects
def parse_relation(relation_hash, relation_sym) def parse_relation(relation_hash, relation_sym)
klass = relation_class(relation_sym) klass = relation_class(relation_sym)
relation_hash.delete('id') #screw IDs for now relation_hash.delete('id')
relation_hash.delete('project_id') unless klass.column_names.include?(:project_id) relation_hash.delete('project_id') unless klass.column_names.include?('project_id')
klass klass
end end
end end
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment