summaryrefslogtreecommitdiff
path: root/archaeological_context_records/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-09-12 12:39:40 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-09-13 13:34:27 +0200
commit296ee1376450adf58a040a9da816a100fa5d2ec9 (patch)
treebf7d12d69c5c3b8670f28a58e524200db008e8a0 /archaeological_context_records/models.py
parentc8a27a7f986adb1e3d0eb911acffa02d030cc85f (diff)
downloadIshtar-296ee1376450adf58a040a9da816a100fa5d2ec9.tar.bz2
Ishtar-296ee1376450adf58a040a9da816a100fa5d2ec9.zip
⚡️ improve performance - external ID: prevent double save - user UPDATE query instead of save - remove dead code "BulkUpdatedItem"
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r--archaeological_context_records/models.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index e13633d90..0ac13e43a 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -52,7 +52,6 @@ from ishtar_common.models import (
post_delete_record_relation,
post_save_cache,
ValueGetter,
- BulkUpdatedItem,
RelationItem,
Town,
get_current_profile,
@@ -461,7 +460,6 @@ class GeographicSubTownItem(GeoItem):
class ContextRecord(
- BulkUpdatedItem,
DocumentItem,
BaseHistorizedItem,
CompleteIdentifierItem,
@@ -1286,8 +1284,15 @@ def context_record_post_save(sender, **kwargs):
cached_label_changed(sender=sender, **kwargs)
post_save_geo(sender=sender, **kwargs)
instance = kwargs.get("instance", None)
- if instance and instance.pk:
- ContextRecordTree.update(instance.pk)
+ if not instance or not instance.pk:
+ return
+ ContextRecordTree.update(instance.pk)
+ BaseFind = apps.get_model("archaeological_finds", "BaseFind")
+ Find = apps.get_model("archaeological_finds", "Find")
+ for bf in instance.base_finds.all():
+ cached_label_changed(BaseFind, instance=bf)
+ for f in bf.find.all():
+ cached_label_changed(Find, instance=f)
post_save.connect(context_record_post_save, sender=ContextRecord)