mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-11 23:54:43 +08:00
adds repository row assets to team import/export [fixes SCI-2165]
This commit is contained in:
parent
4a82d1e7ac
commit
3d7591100a
2 changed files with 20 additions and 10 deletions
|
@ -225,7 +225,8 @@ class TeamExporter
|
||||||
def repository_cell(cell)
|
def repository_cell(cell)
|
||||||
{
|
{
|
||||||
repository_cell: cell,
|
repository_cell: cell,
|
||||||
repository_value: cell.value
|
repository_value: cell.value,
|
||||||
|
repository_value_asset: get_cell_value_asset(cell)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -235,4 +236,10 @@ class TeamExporter
|
||||||
repository_list_items: column.repository_list_items
|
repository_list_items: column.repository_list_items
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_cell_value_asset(cell)
|
||||||
|
return unless cell.value_type == 'RepositoryAssetValue'
|
||||||
|
@assets_to_copy.push(cell.value.asset)
|
||||||
|
cell.value.asset
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -108,7 +108,7 @@ class TeamImporter
|
||||||
|
|
||||||
team_json['repositories'].each do |repository_json|
|
team_json['repositories'].each do |repository_json|
|
||||||
repository_json['repository_rows'].each do |repository_row_json|
|
repository_json['repository_rows'].each do |repository_row_json|
|
||||||
create_repository_cells(repository_row_json['repository_cells'])
|
create_repository_cells(repository_row_json['repository_cells'], team)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ class TeamImporter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_repository_cells(repository_cells_json)
|
def create_repository_cells(repository_cells_json, team)
|
||||||
repository_cells_json.each do |repository_cell_json|
|
repository_cells_json.each do |repository_cell_json|
|
||||||
repository_cell =
|
repository_cell =
|
||||||
RepositoryCell.new(repository_cell_json['repository_cell'])
|
RepositoryCell.new(repository_cell_json['repository_cell'])
|
||||||
|
@ -394,7 +394,8 @@ class TeamImporter
|
||||||
repository_cell.repository_row_id =
|
repository_cell.repository_row_id =
|
||||||
@repository_row_mappings[repository_cell.repository_row_id]
|
@repository_row_mappings[repository_cell.repository_row_id]
|
||||||
create_cell_value(repository_cell,
|
create_cell_value(repository_cell,
|
||||||
repository_cell_json['repository_value'])
|
repository_cell_json,
|
||||||
|
team)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -802,22 +803,24 @@ class TeamImporter
|
||||||
@repository_list_item_mappings[list_item_id]
|
@repository_list_item_mappings[list_item_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_cell_value(repository_cell, value_json)
|
def create_cell_value(repository_cell, value_json, team)
|
||||||
|
cell_json = value_json['repository_value']
|
||||||
case repository_cell.value_type
|
case repository_cell.value_type
|
||||||
when 'RepositoryListValue'
|
when 'RepositoryListValue'
|
||||||
list_item_id = find_list_item_id(value_json['repository_list_item_id'])
|
list_item_id = find_list_item_id(cell_json['repository_list_item_id'])
|
||||||
repository_value = RepositoryListValue.new(
|
repository_value = RepositoryListValue.new(
|
||||||
repository_list_item_id: list_item_id.to_i
|
repository_list_item_id: list_item_id.to_i
|
||||||
)
|
)
|
||||||
when 'RepositoryTextValue'
|
when 'RepositoryTextValue'
|
||||||
repository_value = RepositoryTextValue.new(value_json)
|
repository_value = RepositoryTextValue.new(cell_json)
|
||||||
when 'RepositoryAssetValue'
|
when 'RepositoryAssetValue'
|
||||||
repository_value = RepositoryAssetValue.new()
|
asset = create_asset(value_json['repository_value_asset'], team)
|
||||||
|
repository_value = RepositoryAssetValue.new(asset: asset)
|
||||||
end
|
end
|
||||||
repository_value.id = nil
|
repository_value.id = nil
|
||||||
repository_value.created_by_id = find_user(value_json['created_by_id'])
|
repository_value.created_by_id = find_user(cell_json['created_by_id'])
|
||||||
repository_value.last_modified_by_id =
|
repository_value.last_modified_by_id =
|
||||||
find_user(value_json['last_modified_by_id'])
|
find_user(cell_json['last_modified_by_id'])
|
||||||
repository_value.repository_cell = repository_cell
|
repository_value.repository_cell = repository_cell
|
||||||
repository_value.save!
|
repository_value.save!
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue