mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 20:05:55 +08:00
removes imported repository row if the row value is not valid [fixes SCI-1393]
This commit is contained in:
parent
b5649d3d5b
commit
703be13fb0
1 changed files with 8 additions and 7 deletions
|
@ -90,11 +90,9 @@ class Repository < ActiveRecord::Base
|
||||||
created_by: user,
|
created_by: user,
|
||||||
last_modified_by: user)
|
last_modified_by: user)
|
||||||
|
|
||||||
next unless record_row.save
|
next unless record_row.valid?
|
||||||
nr_of_added += 1
|
|
||||||
sheet.row(i).each.with_index do |value, index|
|
sheet.row(i).each.with_index do |value, index|
|
||||||
if custom_fields[index]
|
if custom_fields[index] && value
|
||||||
# we're working with CustomField
|
|
||||||
rep_column = RepositoryTextValue.new(
|
rep_column = RepositoryTextValue.new(
|
||||||
data: value,
|
data: value,
|
||||||
created_by: user,
|
created_by: user,
|
||||||
|
@ -105,11 +103,14 @@ class Repository < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
error << rep_column.errors.messages unless rep_column.save
|
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 error.any?
|
||||||
|
record_row.destroy
|
||||||
|
else
|
||||||
|
nr_of_added += 1
|
||||||
|
record_row.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if errors.count > 0
|
if errors.count > 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue