diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-28 14:50:12 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-28 14:50:12 +0200 |
commit | c64fd6f05a767282972d9e51c3129993a4b90e1f (patch) | |
tree | 2f2f39dfb5c185d8e8857b2f87bbeff6065bb321 /archaeological_finds | |
parent | 64da49c224d9c8b8271f81bfcc1328d5cc65f5d2 (diff) | |
download | Ishtar-c64fd6f05a767282972d9e51c3129993a4b90e1f.tar.bz2 Ishtar-c64fd6f05a767282972d9e51c3129993a4b90e1f.zip |
Better management of cascade updates
Diffstat (limited to 'archaeological_finds')
-rw-r--r-- | archaeological_finds/migrations/0067_auto_20190628_1257.py | 60 | ||||
-rw-r--r-- | archaeological_finds/tests.py | 46 |
2 files changed, 106 insertions, 0 deletions
diff --git a/archaeological_finds/migrations/0067_auto_20190628_1257.py b/archaeological_finds/migrations/0067_auto_20190628_1257.py new file mode 100644 index 000000000..b8122ce4d --- /dev/null +++ b/archaeological_finds/migrations/0067_auto_20190628_1257.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2019-06-28 12:57 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_finds', '0066_auto_20190527_1811'), + ] + + operations = [ + migrations.AddField( + model_name='basefind', + name='need_update', + field=models.BooleanField(default=False, verbose_name='Need update'), + ), + migrations.AddField( + model_name='find', + name='need_update', + field=models.BooleanField(default=False, verbose_name='Need update'), + ), + migrations.AddField( + model_name='historicalbasefind', + name='need_update', + field=models.BooleanField(default=False, verbose_name='Need update'), + ), + migrations.AddField( + model_name='historicalfind', + name='need_update', + field=models.BooleanField(default=False, verbose_name='Need update'), + ), + migrations.AddField( + model_name='historicaltreatment', + name='need_update', + field=models.BooleanField(default=False, verbose_name='Need update'), + ), + migrations.AddField( + model_name='historicaltreatmentfile', + name='need_update', + field=models.BooleanField(default=False, verbose_name='Need update'), + ), + migrations.AddField( + model_name='property', + name='need_update', + field=models.BooleanField(default=False, verbose_name='Need update'), + ), + migrations.AddField( + model_name='treatment', + name='need_update', + field=models.BooleanField(default=False, verbose_name='Need update'), + ), + migrations.AddField( + model_name='treatmentfile', + name='need_update', + field=models.BooleanField(default=False, verbose_name='Need update'), + ), + ] diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index acd86727b..3d4d6f1d7 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -1672,6 +1672,52 @@ class GeomaticTest(FindInit, TestCase): def setUp(self): self.create_finds(data_base={"label": u"Find 1"}, force=True) + def test_update_container_localisation_on_warehouse_update(self): + profile, created = IshtarSiteProfile.objects.get_or_create( + slug='default', active=True) + profile.mapping = True + profile.save() + wgs84 = SpatialReferenceSystem.objects.get(srid=4326) + + find = self.finds[0] + base_find = find.base_finds.all()[0] + self.assertEqual(base_find.x, None) + + operation = Operation.objects.get( + pk=base_find.context_record.operation.pk + ) + operation.x, operation.y = 33, 42 + operation.spatial_reference_system = wgs84 + operation.save() + + # an update is pending for the linked context record + q = ContextRecord.objects.filter( + pk=base_find.context_record.pk, + need_update=True) + self.assertEqual(q.count(), 1) + + # process pending update + context_record = q.all()[0] + self.assertEqual(context_record.x, None) # update has to be done + context_record.skip_history_when_saving = True + context_record._no_move = True + context_record.save() + context_record = ContextRecord.objects.get(pk=context_record.pk) + self.assertEqual(context_record.x, 33) + + # then an update is pending for the linked base find + q = models.BaseFind.objects.filter(pk=base_find.pk, need_update=True) + self.assertEqual(q.count(), 1) + + # process pending update + bf = q.all()[0] + self.assertEqual(bf.x, None) # update has to be done + bf.skip_history_when_saving = True + bf._no_move = True + bf.save() + bf = models.BaseFind.objects.get(pk=bf.pk) + self.assertEqual(bf.x, 33) + def test_post_save_point(self): find = self.finds[0] base_find = find.base_finds.all()[0] |