summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/models.py3
-rw-r--r--archaeological_context_records/tests.py11
2 files changed, 14 insertions, 0 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 2f9737c14..9ad6da489 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -1222,6 +1222,9 @@ class ContextRecord(
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)
post_save.connect(context_record_post_save, sender=ContextRecord)
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index 0d838f3ea..2804bbc45 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -1101,6 +1101,17 @@ class RecordRelationsTest(ContextRecordInit, TestCase):
1,
)
+ def test_simple_relation_tree(self):
+ profile = get_current_profile()
+ profile.parent_relations_engine = "T"
+ profile.save()
+ get_current_profile(force=True)
+ self.assertTrue(models.ContextRecordTree.check_engine()) # change to table
+ q = models.ContextRecordTree.objects
+ nb = q.count()
+ self.create_context_record({"label": "CR test"})
+ self.assertEqual(q.count(), nb + 1)
+
def test_relation_view(self):
profile = get_current_profile()
profile.parent_relations_engine = "V"