diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-04-09 01:26:27 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-04-24 19:42:35 +0200 |
commit | 36372df20e8d19473c292345713445c599685d8b (patch) | |
tree | f3c87f14656786894e31086be9b73ddcb05bbbb9 /ishtar_common/data_importer.py | |
parent | c831f58beebde59be63227217ed20acfdcf60c79 (diff) | |
download | Ishtar-36372df20e8d19473c292345713445c599685d8b.tar.bz2 Ishtar-36372df20e8d19473c292345713445c599685d8b.zip |
Importers: fix default management
- allow arbitrary values
- allow values directly related to the main model of the import
- add a "get_default" in attribute configuration in order to force use of
default settings
Diffstat (limited to 'ishtar_common/data_importer.py')
-rw-r--r-- | ishtar_common/data_importer.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index d44a19319..baf943068 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1574,6 +1574,9 @@ class Importer(object): if attribute == 'data': # json field # no need to do anything return + if attribute == 'get_default': + # force evaluation of default value for this field + return try: field_object = cls._meta.get_field(attribute) except FieldDoesNotExist: @@ -1720,6 +1723,11 @@ class Importer(object): defaults[k] = dct.pop(k) else: dct.pop(k) + if "get_default" in dct and dct["get_default"]: + dct.pop("get_default") + new_dct = defaults.copy() + new_dct.update(dct) + dct = new_dct obj = None if self.simulate: |