mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-16 16:16:43 +10:00
starting to use the new dynamic stuff on the import
This commit is contained in:
@@ -7,6 +7,10 @@ module Projects
|
||||
{ only: atts_only[:project], include: build_hash(tree) }
|
||||
end
|
||||
|
||||
def tree
|
||||
config[:project_tree]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def config
|
||||
@@ -21,10 +25,6 @@ module Projects
|
||||
config[:attributes_except]
|
||||
end
|
||||
|
||||
def tree
|
||||
config[:project_tree]
|
||||
end
|
||||
|
||||
def build_hash(array)
|
||||
array.map do |el|
|
||||
if el.is_a?(Hash)
|
||||
|
||||
@@ -25,32 +25,41 @@ module Projects
|
||||
#TODO Definitely refactor this method!
|
||||
#TODO Think about having a yaml file to describe the tree instead of just hashes?
|
||||
def create_relations(relation_list = default_relation_list, tree_hash = @tree_hash)
|
||||
members_map # TODO remove this and fix project_members
|
||||
relation_list.each do |relation|
|
||||
relation_hash = nil
|
||||
# FIXME
|
||||
# next if tree_hash[relation.to_s].blank?
|
||||
if (relation.is_a?(Hash) && relation.values.first[:include])
|
||||
#TODO name stuff properly
|
||||
relation_sym = relation.keys.first
|
||||
#TODO remove sub-relation hashes from here so we can save the parent relation first
|
||||
relation_hash = create_relation(relation_sym, tree_hash[relation_sym.to_s])
|
||||
sub_relations = []
|
||||
sub_relation = relation.values.first[:include]
|
||||
sub_relation_hash_list = tree_hash[relation.keys.first.to_s]
|
||||
sub_relation_hash_list.each do |sub_relation_hash|
|
||||
sub_relations << create_relation(relation, sub_relation_hash[relation.to_s])
|
||||
if relation.is_a?(Hash)
|
||||
relation.values.each do |value|
|
||||
create_relations(value, @tree_hash[relation.to_s])
|
||||
end
|
||||
relation_hash.update_attribute(sub_relation, sub_relations)
|
||||
end
|
||||
relation_hash ||= create_relation(relation, tree_hash[relation.to_s])
|
||||
project.update_attribute(relation, relation_hash)
|
||||
relation_hash = create_relation(relation, tree_hash[relation.to_s])
|
||||
project.update_attribute(relation, relation_hash)
|
||||
# relation_hash = nil
|
||||
# # FIXME
|
||||
# # next if tree_hash[relation.to_s].blank?
|
||||
# if (relation.is_a?(Hash) && relation.values.first[:include])
|
||||
# #TODO name stuff properly
|
||||
# relation_sym = relation.keys.first
|
||||
# #TODO remove sub-relation hashes from here so we can save the parent relation first
|
||||
# relation_hash = create_relation(relation_sym, tree_hash[relation_sym.to_s])
|
||||
# sub_relations = []
|
||||
# sub_relation = relation.values.first[:include]
|
||||
# sub_relation_hash_list = tree_hash[relation.keys.first.to_s]
|
||||
# sub_relation_hash_list.each do |sub_relation_hash|
|
||||
# sub_relations << create_relation(relation, sub_relation_hash[relation.to_s])
|
||||
# end
|
||||
# relation_hash.update_attribute(sub_relation, sub_relations)
|
||||
# end
|
||||
# relation_hash ||= create_relation(relation, tree_hash[relation.to_s])
|
||||
# project.update_attribute(relation, relation_hash)
|
||||
end
|
||||
end
|
||||
|
||||
def default_relation_list
|
||||
ImportExport.project_tree.reject do |rel|
|
||||
rel.is_a?(Hash) && !rel[:project_members].blank?
|
||||
end
|
||||
Projects::ImportExport::ImportExportReader.tree
|
||||
# ImportExport.project_tree.reject do |rel|
|
||||
# rel.is_a?(Hash) && !rel[:project_members].blank?
|
||||
# end
|
||||
end
|
||||
|
||||
def project
|
||||
|
||||
Reference in New Issue
Block a user