diff options
-rw-r--r-- | archaeological_context_records/models.py | 5 | ||||
-rw-r--r-- | ishtar_common/data_importer.py | 5 | ||||
-rw-r--r-- | ishtar_common/models_common.py | 10 |
3 files changed, 19 insertions, 1 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 861558c09..210fd7996 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -479,7 +479,10 @@ class GeographicSubTownItem(GeoItem): if main_geodata_id not in self.geodata.values_list("id", flat=True): upper = getattr(self, upper_attr, None) modified = True - self.geodata.add(upper.main_geodata) + try: + self.geodata.add(upper.main_geodata) + except IntegrityError: + pass if not main_item_is_set: if self.main_geodata_id != main_geodata_id: diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index c239b20b4..7bdade5ab 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -950,6 +950,11 @@ class Importer(object): item._timestamp = self.timestamp item._queue = "low_priority" item.save() + if hasattr(item, "post_save_geo"): + # force geo recheck - needed for background task + item = cls.objects.get(pk=pk) + item._queue = "low_priority" + item.post_save_geo() if hasattr(item, "RELATED_POST_PROCESS"): for related_key in item.RELATED_POST_PROCESS: for related in getattr(item, related_key).all(): diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 79aa66953..89471972b 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -3374,6 +3374,16 @@ class MainItem(ShortMenuItem, SerializeItem, SheetItem): self._cached_label_checked = False cached_label_changed(self.__class__, instance=self, created=False) + def no_post_process(self, history=False): + if not history: + self.skip_history_when_saving = True + self._cached_label_checked = True + self._post_saved_geo = True + self._external_id_checked = True + self._search_updated = True + self._no_move = True + self._no_down_model_update = True + def post_save_geo(self, save=True): if getattr(self, "_post_saved_geo", False): return |