mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 06:35:56 +08:00
Merge pull request #7853 from artoscinote/ma_SCI_11050
Import fixes [SCI-11050]
This commit is contained in:
commit
bf1c446cc2
|
@ -133,7 +133,7 @@ class StorageLocationsController < ApplicationController
|
|||
def import_container
|
||||
result = StorageLocations::ImportService.new(@storage_location, params[:file], current_user).import_items
|
||||
if result[:status] == :ok
|
||||
if (result[:assigned_count] + result[:unassigned_count] + result[:updated_count]).positive?
|
||||
if (result[:assigned_count] + result[:unassigned_count]).positive?
|
||||
log_activity(
|
||||
:storage_location_imported,
|
||||
{
|
||||
|
|
|
@ -28,9 +28,9 @@ class StorageLocationRepositoryRow < ApplicationRecord
|
|||
end
|
||||
|
||||
def ensure_uniq_position
|
||||
if StorageLocationRepositoryRow.where(storage_location: storage_location)
|
||||
.where('metadata @> ?', { position: metadata['position'] }.to_json)
|
||||
.where.not(id: id).exists?
|
||||
if storage_location.storage_location_repository_rows
|
||||
.where("metadata->'position' = ?", metadata['position'].to_json)
|
||||
.where.not(id: id).exists?
|
||||
errors.add(:base, I18n.t('activerecord.errors.models.storage_location.not_uniq_position'))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,6 @@ module StorageLocations
|
|||
@storage_location = storage_location
|
||||
@assigned_count = 0
|
||||
@unassigned_count = 0
|
||||
@updated_count = 0
|
||||
@sheet = SpreadsheetParser.open_spreadsheet(file)
|
||||
@user = user
|
||||
end
|
||||
|
@ -73,12 +72,10 @@ module StorageLocations
|
|||
metadata: { position: row[:position] }
|
||||
)
|
||||
|
||||
@assigned_count += 1 if storage_location_repository_row.new_record?
|
||||
|
||||
storage_location_repository_row.update!(
|
||||
repository_row_id: row[:repository_row_id],
|
||||
created_by: storage_location_repository_row.created_by || @user
|
||||
)
|
||||
if storage_location_repository_row.new_record?
|
||||
@assigned_count += 1
|
||||
storage_location_repository_row.update!(created_by: @user)
|
||||
end
|
||||
end
|
||||
|
||||
def unassign_repository_rows!
|
||||
|
|
Loading…
Reference in a new issue