summaryrefslogtreecommitdiff
path: root/archaeological_finds/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-10-22 09:47:33 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-10-22 09:47:33 +0200
commitaf236ef5c089350d03dbfe033d4128f81b6bc515 (patch)
treef4b6d2c1dd642d37eb786703597f40c69c789119 /archaeological_finds/models.py
parent16cb1585a99116d45ec38e5a39122d5e585f614f (diff)
downloadIshtar-af236ef5c089350d03dbfe033d4128f81b6bc515.tar.bz2
Ishtar-af236ef5c089350d03dbfe033d4128f81b6bc515.zip
Improve cached label regeneration when modifying parent items (refs #3341)
Diffstat (limited to 'archaeological_finds/models.py')
-rw-r--r--archaeological_finds/models.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py
index 016bf4d45..5799d0e9a 100644
--- a/archaeological_finds/models.py
+++ b/archaeological_finds/models.py
@@ -645,6 +645,7 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
super(Find, self).save(*args, **kwargs)
updated = False
+ self.skip_history_when_saving = True
if not self.external_id or self.auto_external_id:
external_id = get_external_id('find_external_id', self)
if external_id != self.external_id:
@@ -678,19 +679,16 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
modified = True
base_find.index = BaseFind.get_max_index(
base_find.context_record.operation) + 1
- if not base_find.cache_short_id or \
- not base_find.cache_short_id.endswith(
- unicode(base_find.index)):
- base_find.cache_short_id = base_find.short_id()
- if base_find.cache_short_id:
- modified = True
- if not base_find.cache_complete_id or \
- not base_find.cache_complete_id.endswith(
- unicode(base_find.index)):
- base_find.cache_complete_id = base_find.complete_id()
- if base_find.cache_complete_id:
- modified = True
+ short_id = base_find.short_id()
+ if base_find.cache_short_id != short_id:
+ base_find.cache_short_id = short_id
+ modified = True
+ complete_id = base_find.complete_id()
+ if base_find.cache_complete_id != complete_id:
+ base_find.cache_complete_id = complete_id
+ modified = True
if modified:
+ base_find.skip_history_when_saving = True
base_find.save()
# if not base_find.material_index:
# idx = BaseFind.objects\