diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index ee28d27f7..86ed5b094 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -181,15 +181,15 @@ class RepositoriesController < ApplicationController end def parse_sheet - repository = current_team.repositories.find_by_id(params[:id]) + repository = current_team.repositories.find_by_id(import_params[:id]) - unless params[:file] + unless import_params[:file] repository_response(t('teams.parse_sheet.errors.no_file_selected')) return end begin parsed_file = ImportRepository::ParseRepository.new( - file: params[:file], + file: import_params[:file], repository: repository, session: session ) @@ -229,7 +229,7 @@ class RepositoriesController < ApplicationController respond_to do |format| format.json do # Check if there exist mapping for repository record (it's mandatory) - if params[:mappings].value?('-1') + if import_params[:mappings].value?('-1') import_records = repostiory_import_actions status = import_records.import! @@ -272,9 +272,9 @@ class RepositoriesController < ApplicationController def repostiory_import_actions ImportRepository::ImportRecords.new( - temp_file: TempFile.find_by_id(params[:file_id]), - repository: current_team.repositories.find_by_id(params[:id]), - mappings: params[:mappings], + temp_file: TempFile.find_by_id(import_params[:file_id]), + repository: current_team.repositories.find_by_id(import_params[:id]), + mappings: import_params[:mappings], session: session, user: current_user ) @@ -317,6 +317,10 @@ class RepositoriesController < ApplicationController params.require(:repository).permit(:name) end + def import_params + params.permit(:id, :file, :file_id, mappings: {}).to_h + end + def repository_response(message) respond_to do |format| format.html do diff --git a/app/models/repository.rb b/app/models/repository.rb index 230f45f66..eda5e3d76 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -161,12 +161,7 @@ class Repository < ApplicationRecord repository_column: columns[index] } ) - cell = RepositoryCell.new(repository_row: record_row, - repository_column: columns[index], - value: cell_value) - cell.skip_on_import = true - cell_value.repository_cell = cell - unless cell.valid? && cell_value.valid? + unless cell_value.valid? errors = true raise ActiveRecord::Rollback end diff --git a/app/views/repositories/_import_repository_records_modal.html.erb b/app/views/repositories/_import_repository_records_modal.html.erb index 80d574f96..f545749fa 100644 --- a/app/views/repositories/_import_repository_records_modal.html.erb +++ b/app/views/repositories/_import_repository_records_modal.html.erb @@ -16,7 +16,7 @@
<% end %> diff --git a/app/views/repositories/_parse_records_modal.html.erb b/app/views/repositories/_parse_records_modal.html.erb index 7a15968ba..693b12650 100644 --- a/app/views/repositories/_parse_records_modal.html.erb +++ b/app/views/repositories/_parse_records_modal.html.erb @@ -65,7 +65,7 @@ <% end %>