Commit da60baf2 authored by James Lopez's avatar James Lopez

fixing more importing issues

parent 56fc5893
......@@ -37,7 +37,9 @@ class MergeRequestDiff < ActiveRecord::Base
serialize :st_commits
serialize :st_diffs
after_create :reload_content
after_create :reload_content, unless: :importing
attr_accessor :importing
def reload_content
reload_commits
......
......@@ -71,9 +71,10 @@ module Projects
# TODO refactor this
relation_key = relation.keys.first
tree_hash[relation_key.to_s].each do |relation_item|
relation.values.each do |sub_relation|
relation.values.flatten.each do |sub_relation|
relation_hash = relation_item[sub_relation.to_s]
next if relation_hash.blank?
relation_hash.merge!('project_id' => project.id) if sub_relation == :merge_requests
sub_relation_object = Projects::ImportExport::RelationFactory.create(
relation_sym: sub_relation, relation_hash: relation_hash, members_map: members_map)
relation_item[sub_relation.to_s] = sub_relation_object
......
......@@ -7,12 +7,14 @@ module Projects
USER_REFERENCES = %w(author_id assignee_id updated_by_id).freeze
def create(relation_sym:, relation_hash:, members_map:)
#TODO refactor this
relation_sym = parse_relation_sym(relation_sym)
klass = relation_class(relation_sym)
relation_hash.delete('id') #screw IDs for now
handle_merge_requests(relation_hash) if relation_sym == :merge_requests
update_user_references(relation_hash, members_map)
klass.new(relation_hash)
imported_object = klass.new(relation_hash)
imported_object.importing = true if imported_object.respond_to?(:importing)
end
private
......@@ -20,7 +22,6 @@ module Projects
def handle_merge_requests(relation_hash)
relation_hash['target_project_id'] = relation_hash.delete('project_id')
relation_hash['source_project_id'] = -1
relation_hash['importing'] = true
end
#TODO nice to have, optimize this to only get called for specific models
......
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