diff options
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 |
commit | 53888c24ca9dc156e5ffa0dc66e1bf36a00085a0 (patch) | |
tree | f4b6d2c1dd642d37eb786703597f40c69c789119 /archaeological_operations/models.py | |
parent | 4894a53ebb007d80f2a602147481645358ab4ab7 (diff) | |
download | Ishtar-53888c24ca9dc156e5ffa0dc66e1bf36a00085a0.tar.bz2 Ishtar-53888c24ca9dc156e5ffa0dc66e1bf36a00085a0.zip |
Improve cached label regeneration when modifying parent items (refs #3341)
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index fbac96975..14e5e1f7e 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -433,6 +433,9 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms, cached_label = settings.JOINT.join(items) return cached_label + def _get_associated_cached_labels(self): + return list(self.context_record.all()) + def get_town_label(self): lbl = unicode(_('Intercommunal')) if self.towns.count() == 1: @@ -747,6 +750,7 @@ def operation_post_save(sender, **kwargs): if not kwargs['instance']: return operation = kwargs['instance'] + operation.skip_history_when_saving = True if operation.fnap_financing and operation.cost: fnap_cost = int(float(operation.cost) / 100 * operation.fnap_financing) if not operation.fnap_cost or operation.fnap_cost != fnap_cost: @@ -754,8 +758,9 @@ def operation_post_save(sender, **kwargs): operation.save() elif operation.fnap_cost and operation.cost: fnap_percent = float(operation.fnap_cost) * 100 / operation.cost - operation.fnap_financing = fnap_percent - operation.save() + if operation.fnap_financing != fnap_percent: + operation.fnap_financing = fnap_percent + operation.save() cached_label_changed(sender, **kwargs) if operation.associated_file: operation.associated_file.update_short_menu_class() |