From f4bad8942ed753b85fcf7bdb00ce666bebe53c97 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 21 Jan 2018 20:28:02 +0100 Subject: Administrativ act: adapt forms, models and sheet --- ishtar_common/models.py | 4 ++++ ishtar_common/utils.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index eb84f8a7e..3af92a39e 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1030,6 +1030,10 @@ class FullSearch(models.Model): :param save: True if you want to save the object immediately :return: True if modified """ + if not self.pk: + logger.warning("Cannot update search vector before save or " + "after deletion.") + return if not self.BASE_SEARCH_VECTORS and not self.M2M_SEARCH_VECTORS \ and not self.INT_SEARCH_VECTORS \ and not self.PARENT_SEARCH_VECTORS: diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 4ecddfc92..23020ac95 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -129,11 +129,11 @@ def cached_label_changed(sender, **kwargs): if hasattr(instance, '_cascade_change') and instance._cascade_change: instance.skip_history_when_saving = True instance.save() - if hasattr(instance, 'update_search_vector'): - instance.update_search_vector() updated = False + if hasattr(instance, 'update_search_vector'): + updated = instance.update_search_vector() if hasattr(instance, '_cached_labels_bulk_update'): - updated = instance._cached_labels_bulk_update() + updated = instance._cached_labels_bulk_update() or updated if not updated and hasattr(instance, '_get_associated_cached_labels'): for item in instance._get_associated_cached_labels(): item._cascade_change = True -- cgit v1.2.3