summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-22 11:28:15 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-22 11:28:15 +0100
commitc706f8677b1e2c04876244b103e37b2c6ef346e5 (patch)
treeccae74a7d858255f3730029595fa018182e2b646
parent7d5d412dc193e74346838aa0f2ae440c1c652cff (diff)
downloadIshtar-c706f8677b1e2c04876244b103e37b2c6ef346e5.tar.bz2
Ishtar-c706f8677b1e2c04876244b103e37b2c6ef346e5.zip
Fix localisation update in finds
-rw-r--r--archaeological_warehouse/models.py4
-rw-r--r--ishtar_common/utils.py5
2 files changed, 6 insertions, 3 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index 3e2b87551..65b5728f9 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -660,4 +660,6 @@ class ContainerLocalisation(models.Model):
def save(self, *args, **kwargs):
super(ContainerLocalisation, self).save(*args, **kwargs)
- cached_label_changed(Container, instance=self.container)
+ self.container.skip_history_when_saving = True
+ cached_label_changed(Container, instance=self.container,
+ force_update=True)
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 562992bdb..f2fe34631 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -295,11 +295,12 @@ def cached_label_changed(sender, **kwargs):
if not kwargs.get('instance'):
return
instance = kwargs.get('instance')
+ force_update = kwargs.get('force_update', False)
if hasattr(instance, 'test_obj'):
instance.test_obj.reached(sender, **kwargs)
- if hasattr(instance, '_cached_label_checked') \
+ if not force_update and hasattr(instance, '_cached_label_checked') \
and instance._cached_label_checked:
return
instance._cached_label_checked = True
@@ -318,7 +319,7 @@ def cached_label_changed(sender, **kwargs):
instance.skip_history_when_saving = True
instance.save()
updated = False
- if hasattr(instance, 'update_search_vector'):
+ if force_update or hasattr(instance, 'update_search_vector'):
updated = instance.update_search_vector()
if hasattr(instance, '_cached_labels_bulk_update'):
updated = instance._cached_labels_bulk_update() or updated