mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 06:04:35 +08:00
fix hound
This commit is contained in:
parent
f66fb49b56
commit
18fd5b00ba
3 changed files with 27 additions and 34 deletions
|
@ -197,7 +197,7 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
unless params[:file]
|
||||
repository_response(t("teams.parse_sheet.errors.no_file_selected"))
|
||||
repository_response(t('teams.parse_sheet.errors.no_file_selected'))
|
||||
return
|
||||
end
|
||||
begin
|
||||
|
@ -244,7 +244,6 @@ class RepositoriesController < ApplicationController
|
|||
render json: {}, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -71,13 +71,13 @@ class Repository < ActiveRecord::Base
|
|||
name_index = -1
|
||||
nr_of_added = 0
|
||||
|
||||
mappings.each.with_index do |(k, v), i|
|
||||
if v == '-1'
|
||||
mappings.each.with_index do |(_k, value), index|
|
||||
if value == '-1'
|
||||
# Fill blank space, so our indices stay the same
|
||||
custom_fields << nil
|
||||
name_index = i
|
||||
name_index = index
|
||||
else
|
||||
cf = repository_columns.find_by_id(v)
|
||||
cf = repository_columns.find_by_id(value)
|
||||
custom_fields << cf
|
||||
end
|
||||
end
|
||||
|
@ -91,7 +91,7 @@ class Repository < ActiveRecord::Base
|
|||
created_by: user,
|
||||
last_modified_by: user)
|
||||
|
||||
if record_row.save
|
||||
next unless record_row.save
|
||||
sheet.row(i).each.with_index do |value, index|
|
||||
if custom_fields[index]
|
||||
# we're working with CustomField
|
||||
|
@ -104,17 +104,13 @@ class Repository < ActiveRecord::Base
|
|||
repository_column: custom_fields[index]
|
||||
}
|
||||
)
|
||||
|
||||
if !rep_column.save
|
||||
error << rep_column.errors.messages
|
||||
end
|
||||
error << rep_column.errors.messages unless rep_column.save
|
||||
else
|
||||
# This custom_field does not exist
|
||||
error << { '#{mappings[index]}': 'Does not exists' }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if errors.count > 0
|
||||
return { status: :error, errors: errors, nr_of_added: nr_of_added }
|
||||
|
|
|
@ -17,11 +17,9 @@ module ImportRepository
|
|||
private
|
||||
|
||||
def run_import_actions
|
||||
@repository.import_records(
|
||||
@repository.open_spreadsheet(@temp_file.file),
|
||||
@repository.import_records(@repository.open_spreadsheet(@temp_file.file),
|
||||
@mappings,
|
||||
@user
|
||||
)
|
||||
@user)
|
||||
end
|
||||
|
||||
def run_checks
|
||||
|
@ -32,7 +30,7 @@ module ImportRepository
|
|||
I18n.t('repositories.import_records.error_message.no_data_to_parse')
|
||||
}
|
||||
end
|
||||
unless @mappings.has_value?('-1')
|
||||
unless @mappings.value?('-1')
|
||||
return {
|
||||
status: :error,
|
||||
errors:
|
||||
|
|
Loading…
Add table
Reference in a new issue