diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-03-22 13:10:52 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-03-22 13:23:14 +0100 |
commit | a4b5f36facba9d2d8685c796acda7d4c35e3c51e (patch) | |
tree | 594e31ccbf84130a79565b70b54cbe5318e59d80 /ishtar_common/models_imports.py | |
parent | af5f58021b975d2bd4081ac80cc9976f096d3a16 (diff) | |
download | Ishtar-a4b5f36facba9d2d8685c796acda7d4c35e3c51e.tar.bz2 Ishtar-a4b5f36facba9d2d8685c796acda7d4c35e3c51e.zip |
✨ Debug mode for imports
Diffstat (limited to 'ishtar_common/models_imports.py')
-rw-r--r-- | ishtar_common/models_imports.py | 9 |
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" |