imp_exp 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/services/imp_exp/importers/base.rb +15 -3
- data/config/locales/en.yml +1 -0
- data/config/locales/fr.yml +2 -1
- data/lib/imp_exp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b590fb77458ecbbde482ccc594ac06b3480551b6f32ad6361c9e34b30cd4c49b
|
|
4
|
+
data.tar.gz: 5ac34f8c6a50ec3a2d1571ffa83ccb9a07241c1822ab4860b217d3980c941961
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1551c0ad5706897955e9be29229686b9b1c65b0307654114c23dea08ce62771e90bbdcbcc5df867012b0ed9e8774caffded874cc5d4da6ed62ecc450e9c14162
|
|
7
|
+
data.tar.gz: b677f5e62d8e066bc1254efdfc00faa15f39266ddb95945d2e800f5178b912a25e87cc14ff7a80d0d4ae9a789b7ae5d4908cd23eb7ace35dede73161c011c4da
|
|
@@ -81,9 +81,15 @@ module ImpExp
|
|
|
81
81
|
next
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
begin
|
|
85
|
+
if record.save(context: :import)
|
|
86
|
+
model.after_save(record)
|
|
87
|
+
@imported[model.model_name] += 1
|
|
88
|
+
next
|
|
89
|
+
end
|
|
90
|
+
rescue ActiveRecord::RecordNotUnique => e
|
|
91
|
+
message = I18n.t('imp_exp.importer.record_not_unique', details: unique_violation_details_suffix(e))
|
|
92
|
+
upsert_error_messages(model_name, line, row.to_s, message)
|
|
87
93
|
next
|
|
88
94
|
end
|
|
89
95
|
|
|
@@ -97,6 +103,12 @@ module ImpExp
|
|
|
97
103
|
Rails.env.local?
|
|
98
104
|
end
|
|
99
105
|
|
|
106
|
+
def unique_violation_details_suffix(exception)
|
|
107
|
+
details = exception.cause&.message || exception.message
|
|
108
|
+
details = details.to_s.strip
|
|
109
|
+
details.present? ? "(#{details})" : ""
|
|
110
|
+
end
|
|
111
|
+
|
|
100
112
|
def attributes_from_row(row, model)
|
|
101
113
|
row.slice(*model.attribute_to_import_names)
|
|
102
114
|
end
|
data/config/locales/en.yml
CHANGED
|
@@ -4,6 +4,7 @@ en:
|
|
|
4
4
|
invalid_columns: "The %{model_name} sheet does not contain the expected columns. Expected columns: %{expected_columns} Columns in the file: %{in_file_columns}."
|
|
5
5
|
invalid_sheets: "The file does not contain the expected sheets. Expected sheets: %{expected_sheets} Sheets in the file: %{in_file_sheets}."
|
|
6
6
|
record_not_found: "%{model_name} with %{conditions} conditions has not been found."
|
|
7
|
+
record_not_unique: "Unique constraint violation. Check the code field. Details: %{details}."
|
|
7
8
|
wrong_format: "Format error: %{message}."
|
|
8
9
|
model_errors: "%{model_name} sheet - Row %{line}: %{messages}"
|
|
9
10
|
data_validation_error: "%{model_name} sheet - Row %{line} - Column \"%{column}\": value \"%{value}\" incorrect, expected value: %{expected}"
|
data/config/locales/fr.yml
CHANGED
|
@@ -4,7 +4,8 @@ fr:
|
|
|
4
4
|
invalid_columns: "La feuille %{model_name} ne contient pas les colonnes attendues. Colonnes attendues : %{expected_columns}. Colonnes dans le fichier : %{in_file_columns}."
|
|
5
5
|
invalid_sheets: "Le fichier ne contient pas les feuilles attendues. Feuilles attendues : %{expected_sheets}. Feuilles dans le fichier : %{in_file_sheets}."
|
|
6
6
|
record_not_found: "%{model_name} avec les conditions %{conditions} n'a pas été trouvé."
|
|
7
|
+
record_not_unique: "Violation de contrainte d'unicité. Vérifiez les champs code. Détails : %{details}."
|
|
7
8
|
wrong_format: "Erreur de format : %{message}."
|
|
8
9
|
model_errors: "Feuille %{model_name} - Ligne %{line} : %{messages}"
|
|
9
10
|
data_validation_error: "Feuille %{model_name} - Ligne %{line} - Colonne \"%{column}\" : valeur \"%{value}\" incorrecte, valeur attendue : %{expected}"
|
|
10
|
-
file_not_found: "Fichier %{file_path} non trouvé."
|
|
11
|
+
file_not_found: "Fichier %{file_path} non trouvé."
|
data/lib/imp_exp/version.rb
CHANGED