diff --git a/app/models/repository_checklist_value.rb b/app/models/repository_checklist_value.rb index e7311c56c..0641f1b0d 100644 --- a/app/models/repository_checklist_value.rb +++ b/app/models/repository_checklist_value.rb @@ -53,7 +53,7 @@ class RepositoryChecklistValue < ApplicationRecord value end - def self.import_from_text(text, attributes) + def self.import_from_text(text, attributes, _options = {}) value = new(attributes) column = attributes.dig(:repository_cell_attributes, :repository_column) text.split("\n").each do |item_text| diff --git a/app/models/repository_date_time_value_base.rb b/app/models/repository_date_time_value_base.rb index 96259ed97..9408b46d0 100644 --- a/app/models/repository_date_time_value_base.rb +++ b/app/models/repository_date_time_value_base.rb @@ -25,8 +25,9 @@ class RepositoryDateTimeValueBase < ApplicationRecord save! end - def self.import_from_text(text, attributes) - new(attributes.merge(data: DateTime.parse(text))) + def self.import_from_text(text, attributes, options = {}) + date_format = options.dig(:user, :settings, :date_format) || Constants::DEFAULT_DATE_FORMAT + new(attributes.merge(data: DateTime.strptime(text, date_format))) rescue ArgumentError nil end diff --git a/app/models/repository_list_value.rb b/app/models/repository_list_value.rb index 82431dbe4..9923dda5f 100644 --- a/app/models/repository_list_value.rb +++ b/app/models/repository_list_value.rb @@ -51,7 +51,7 @@ class RepositoryListValue < ApplicationRecord value end - def self.import_from_text(text, attributes) + def self.import_from_text(text, attributes, _options = {}) value = new(attributes) column = attributes.dig(:repository_cell_attributes, :repository_column) list_item = column.repository_list_items.find { |item| item.data == text } diff --git a/app/models/repository_number_value.rb b/app/models/repository_number_value.rb index af569baea..9ee3eac7d 100644 --- a/app/models/repository_number_value.rb +++ b/app/models/repository_number_value.rb @@ -34,7 +34,7 @@ class RepositoryNumberValue < ApplicationRecord value end - def self.import_from_text(text, attributes) + def self.import_from_text(text, attributes, _options = {}) new(attributes.merge(data: BigDecimal(text))) rescue ArgumentError nil diff --git a/app/models/repository_status_value.rb b/app/models/repository_status_value.rb index 8e657b2c5..7398a42aa 100644 --- a/app/models/repository_status_value.rb +++ b/app/models/repository_status_value.rb @@ -44,7 +44,7 @@ class RepositoryStatusValue < ApplicationRecord value end - def self.import_from_text(text, attributes) + def self.import_from_text(text, attributes, _options = {}) icon = text[0] status = text[1..-1].strip value = new(attributes) diff --git a/app/models/repository_text_value.rb b/app/models/repository_text_value.rb index f91e233db..9d34d8553 100644 --- a/app/models/repository_text_value.rb +++ b/app/models/repository_text_value.rb @@ -33,7 +33,7 @@ class RepositoryTextValue < ApplicationRecord value end - def self.import_from_text(text, attributes) + def self.import_from_text(text, attributes, _options = {}) return nil if text.blank? new(attributes.merge(data: text.truncate(Constants::TEXT_MAX_LENGTH))) diff --git a/app/utilities/repository_import_parser/importer.rb b/app/utilities/repository_import_parser/importer.rb index ba9c2b326..72855c8c7 100644 --- a/app/utilities/repository_import_parser/importer.rb +++ b/app/utilities/repository_import_parser/importer.rb @@ -134,7 +134,11 @@ module RepositoryImportParser repository_column: column, importing: true } } - cell_value = column.data_type.constantize.import_from_text(value, cell_value_attributes) + cell_value = column.data_type.constantize.import_from_text( + value, + cell_value_attributes, + user: @user.as_json + ) next if cell_value.nil? cell_value.repository_cell.value = cell_value