summaryrefslogtreecommitdiff
path: root/archaeological_context_records
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
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')
-rw-r--r--archaeological_context_records/migrations/0101_squashed.py3
-rw-r--r--archaeological_context_records/models.py13
2 files changed, 10 insertions, 6 deletions
diff --git a/archaeological_context_records/migrations/0101_squashed.py b/archaeological_context_records/migrations/0101_squashed.py
index fcdf81789..119e28b61 100644
--- a/archaeological_context_records/migrations/0101_squashed.py
+++ b/archaeological_context_records/migrations/0101_squashed.py
@@ -111,8 +111,7 @@ class Migration(migrations.Migration):
'ordering': ('cached_label',),
'permissions': (('view_own_contextrecord', 'Can view own Context Record'), ('add_own_contextrecord', 'Can add own Context Record'), ('change_own_contextrecord', 'Can change own Context Record'), ('delete_own_contextrecord', 'Can delete own Context Record')),
},
- bases=(ishtar_common.models.BulkUpdatedItem,
- ishtar_common.models.DocumentItem,
+ bases=(ishtar_common.models.DocumentItem,
ishtar_common.models.StatisticItem,
ishtar_common.models.TemplateItem,
ishtar_common.models.OwnPerms,
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)