summaryrefslogtreecommitdiff
path: root/ishtar_common/models_imports.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-03-22 13:10:52 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-04-16 16:43:03 +0200
commit13d4acddf63858e59c798837cf4c1f2d29945dd7 (patch)
tree8098f0883d836d54829ddcbf8a092592ffaa97bb /ishtar_common/models_imports.py
parentaa4b31a9638041b7ea849528f6fff45734d68ecf (diff)
downloadIshtar-13d4acddf63858e59c798837cf4c1f2d29945dd7.tar.bz2
Ishtar-13d4acddf63858e59c798837cf4c1f2d29945dd7.zip
✨ Debug mode for imports
Diffstat (limited to 'ishtar_common/models_imports.py')
-rw-r--r--ishtar_common/models_imports.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py
index b25fdc684..51d678401 100644
--- a/ishtar_common/models_imports.py
+++ b/ishtar_common/models_imports.py
@@ -73,6 +73,7 @@ from ishtar_common.utils import (
get_all_related_m2m_objects_with_model,
get_session_var,
import_class,
+ StrJSONEncoder,
max_size_help,
num2col,
put_session_message,
@@ -211,6 +212,7 @@ class ImporterType(models.Model):
help_text=_("If an error is encountered with the following character strings, the error is not reported in "
"the error file. Each message is separated with a line break.")
)
+ debug = models.BooleanField(verbose_name=_("Debug"), default=False)
objects = SlugModelManager()
SERIALIZATION_EXCLUDE = ["users"]
@@ -395,6 +397,7 @@ class ImporterType(models.Model):
"MODEL_CREATION_LIMIT": MODEL_CREATION_LIMIT,
"TYPE": self.type,
"MAIN_GEO": self.is_main_geometry,
+ "DEBUG": self.debug
}
name = str(
"".join(
@@ -1977,6 +1980,7 @@ class Import(BaseImport):
next_import = models.ForeignKey(
"Import", blank=True, null=True, on_delete=models.SET_NULL,
verbose_name=_("Next import"), related_name="imports")
+ debug = models.TextField(verbose_name=_("Debug"), blank=True, default="")
class Meta:
verbose_name = _("Import - Import")
@@ -2608,6 +2612,8 @@ class Import(BaseImport):
self.state = "PI"
else:
self.state = "FE"
+ if importer.debug:
+ self.debug = json.dumps(importer.debug, cls=StrJSONEncoder, indent=2)
self.save()
if not return_importer_and_data:
return
@@ -2619,7 +2625,8 @@ class Import(BaseImport):
self.result_file.save(
result_file, ContentFile(importer.get_csv_result().encode("utf-8"))
)
-
+ if importer.debug:
+ self.debug = json.dumps(importer.debug, cls=StrJSONEncoder, indent=2)
if importer.errors:
if line_to_process:
self.state = "PI"