diff options
-rw-r--r-- | archaeological_finds/models_finds.py | 18 | ||||
-rw-r--r-- | archaeological_warehouse/models.py | 9 | ||||
-rw-r--r-- | ishtar_common/data_importer.py | 6 |
3 files changed, 33 insertions, 0 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 36a1c08c7..c98f72f2a 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -2285,74 +2285,92 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, @post_importer_action def set_reference_localisation_1(self, context, value): return self.set_localisation(0, context, value, is_ref=True) + set_reference_localisation_1.post_save = True @post_importer_action def set_reference_localisation_2(self, context, value): return self.set_localisation(1, context, value, is_ref=True) + set_reference_localisation_2.post_save = True @post_importer_action def set_reference_localisation_3(self, context, value): return self.set_localisation(2, context, value, is_ref=True) + set_reference_localisation_3.post_save = True @post_importer_action def set_reference_localisation_4(self, context, value): return self.set_localisation(3, context, value, is_ref=True) + set_reference_localisation_4.post_save = True @post_importer_action def set_reference_localisation_5(self, context, value): return self.set_localisation(4, context, value, is_ref=True) + set_reference_localisation_5.post_save = True @post_importer_action def set_reference_localisation_6(self, context, value): return self.set_localisation(5, context, value, is_ref=True) + set_reference_localisation_6.post_save = True @post_importer_action def set_reference_localisation_7(self, context, value): return self.set_localisation(6, context, value, is_ref=True) + set_reference_localisation_7.post_save = True @post_importer_action def set_reference_localisation_8(self, context, value): return self.set_localisation(7, context, value, is_ref=True) + set_reference_localisation_8.post_save = True @post_importer_action def set_reference_localisation_9(self, context, value): return self.set_localisation(8, context, value, is_ref=True) + set_reference_localisation_9.post_save = True @post_importer_action def set_localisation_1(self, context, value): return self.set_localisation(0, context, value) + set_localisation_1.post_save = True @post_importer_action def set_localisation_2(self, context, value): return self.set_localisation(1, context, value) + set_localisation_2.post_save = True @post_importer_action def set_localisation_3(self, context, value): return self.set_localisation(2, context, value) + set_localisation_3.post_save = True @post_importer_action def set_localisation_4(self, context, value): return self.set_localisation(3, context, value) + set_localisation_4.post_save = True @post_importer_action def set_localisation_5(self, context, value): return self.set_localisation(4, context, value) + set_localisation_5.post_save = True @post_importer_action def set_localisation_6(self, context, value): return self.set_localisation(5, context, value) + set_localisation_6.post_save = True @post_importer_action def set_localisation_7(self, context, value): return self.set_localisation(6, context, value) + set_localisation_7.post_save = True @post_importer_action def set_localisation_8(self, context, value): return self.set_localisation(7, context, value) + set_localisation_8.post_save = True @post_importer_action def set_localisation_9(self, context, value): return self.set_localisation(8, context, value) + set_localisation_9.post_save = True def generate_index(self): """ diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index beddbf55e..de567d26e 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -800,38 +800,47 @@ class Container(DocumentItem, LightHistorizedItem, QRCodeItem, GeoItem, @post_importer_action def set_localisation_1(self, context, value): return self.set_localisation(0, value) + set_localisation_1.post_save = True @post_importer_action def set_localisation_2(self, context, value): return self.set_localisation(1, value) + set_localisation_2.post_save = True @post_importer_action def set_localisation_3(self, context, value): return self.set_localisation(2, value) + set_localisation_3.post_save = True @post_importer_action def set_localisation_4(self, context, value): return self.set_localisation(3, value) + set_localisation_4.post_save = True @post_importer_action def set_localisation_5(self, context, value): return self.set_localisation(4, value) + set_localisation_5.post_save = True @post_importer_action def set_localisation_6(self, context, value): return self.set_localisation(5, value) + set_localisation_6.post_save = True @post_importer_action def set_localisation_7(self, context, value): return self.set_localisation(6, value) + set_localisation_7.post_save = True @post_importer_action def set_localisation_8(self, context, value): return self.set_localisation(7, value) + set_localisation_8.post_save = True @post_importer_action def set_localisation_9(self, context, value): return self.set_localisation(8, value) + set_localisation_9.post_save = True def get_extra_actions(self, request): """ diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index b0e01d70d..85c5437d1 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1734,12 +1734,16 @@ class Importer(object): }) created = False + post_save_keys = [] try: try: dct = create_dict.copy() for key in dct: if callable(dct[key]): dct[key] = dct[key]() + if getattr(dct[key], "post_save", True): + dct.pop(key) + post_save_keys.append(key) if '__force_new' in dct: created = dct.pop('__force_new') if not [k for k in dct if dct[k] is not None]: @@ -1853,6 +1857,8 @@ class Importer(object): dct.pop('defaults') raise IntegrityError(str(e)) # obj = cls.objects.filter(**dct).all()[0] + for key in post_save_keys: + getattr(obj, key)() for attr, value in m2ms: values = [value] if type(value) in (list, tuple): |