mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 13:44:23 +08:00
Limits the max. amount of rows when importing into inventories [fixes SCI-2468]
This commit is contained in:
parent
58e6701b0a
commit
9abf50e7c5
4 changed files with 12 additions and 0 deletions
|
@ -192,6 +192,11 @@ class RepositoriesController < ApplicationController
|
||||||
if parsed_file.too_large?
|
if parsed_file.too_large?
|
||||||
repository_response(t('general.file.size_exceeded',
|
repository_response(t('general.file.size_exceeded',
|
||||||
file_size: Constants::FILE_MAX_SIZE_MB))
|
file_size: Constants::FILE_MAX_SIZE_MB))
|
||||||
|
elsif parsed_file.has_too_many_rows?
|
||||||
|
repository_response(
|
||||||
|
t('repositories.import_records.error_message.items_limit',
|
||||||
|
items_size: Constants::IMPORT_REPOSITORY_ITEMS_LIMIT)
|
||||||
|
)
|
||||||
else
|
else
|
||||||
@import_data = parsed_file.data
|
@import_data = parsed_file.data
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,10 @@ module ImportRepository
|
||||||
@file.size > Constants::FILE_MAX_SIZE_MB.megabytes
|
@file.size > Constants::FILE_MAX_SIZE_MB.megabytes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_too_many_rows?
|
||||||
|
@sheet.last_row > Constants::IMPORT_REPOSITORY_ITEMS_LIMIT
|
||||||
|
end
|
||||||
|
|
||||||
def generate_temp_file
|
def generate_temp_file
|
||||||
# Save file for next step (importing)
|
# Save file for next step (importing)
|
||||||
temp_file = TempFile.new(
|
temp_file = TempFile.new(
|
||||||
|
|
|
@ -873,6 +873,8 @@ class Constants
|
||||||
|
|
||||||
REPOSITORY_LIST_ITEMS_PER_COLUMN = 500
|
REPOSITORY_LIST_ITEMS_PER_COLUMN = 500
|
||||||
|
|
||||||
|
IMPORT_REPOSITORY_ITEMS_LIMIT = 2000
|
||||||
|
|
||||||
# Very basic regex to check for validity of emails
|
# Very basic regex to check for validity of emails
|
||||||
BASIC_EMAIL_REGEX = URI::MailTo::EMAIL_REGEXP
|
BASIC_EMAIL_REGEX = URI::MailTo::EMAIL_REGEXP
|
||||||
|
|
||||||
|
|
|
@ -959,6 +959,7 @@ en:
|
||||||
success_flash: "%{number_of_rows} new item(s) successfully imported."
|
success_flash: "%{number_of_rows} new item(s) successfully imported."
|
||||||
partial_success_flash: "%{nr} of %{total_nr} successfully imported. Other rows contained errors."
|
partial_success_flash: "%{nr} of %{total_nr} successfully imported. Other rows contained errors."
|
||||||
error_message:
|
error_message:
|
||||||
|
items_limit: "The imported file contains too many rows. Max %{items_size} items allowed to upload at once."
|
||||||
temp_file_not_found: "This file could not be found. Your session might expire."
|
temp_file_not_found: "This file could not be found. Your session might expire."
|
||||||
session_expired: "Your session expired. Please try again."
|
session_expired: "Your session expired. Please try again."
|
||||||
no_data_to_parse: "There's nothing to be parsed."
|
no_data_to_parse: "There's nothing to be parsed."
|
||||||
|
|
Loading…
Add table
Reference in a new issue