removes imported repository row if the row value is not valid [fixes SCI-1393]

This commit is contained in:
zmagod 2017-06-22 15:21:36 +02:00
parent b5649d3d5b
commit 703be13fb0

View file

@ -90,11 +90,9 @@ class Repository < ActiveRecord::Base
created_by: user,
last_modified_by: user)
next unless record_row.save
nr_of_added += 1
next unless record_row.valid?
sheet.row(i).each.with_index do |value, index|
if custom_fields[index]
# we're working with CustomField
if custom_fields[index] && value
rep_column = RepositoryTextValue.new(
data: value,
created_by: user,
@ -105,11 +103,14 @@ class Repository < ActiveRecord::Base
}
)
error << rep_column.errors.messages unless rep_column.save
else
# This custom_field does not exist
error << { '#{mappings[index]}': 'Does not exists' }
end
end
if error.any?
record_row.destroy
else
nr_of_added += 1
record_row.save
end
end
if errors.count > 0