diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-01 18:10:02 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-13 18:26:03 +0200 |
commit | fd89abf54954a22534d769f27a62608f32c367fa (patch) | |
tree | 86516f6293627e14d0d9a3ad35dd8d7dd17e189c /archaeological_operations | |
parent | 3a8aa349b06129c4a8f591d56147ce0c97d4d9c5 (diff) | |
download | Ishtar-fd89abf54954a22534d769f27a62608f32c367fa.tar.bz2 Ishtar-fd89abf54954a22534d769f27a62608f32c367fa.zip |
Rstore lost parcel
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/models.py | 9 | ||||
-rw-r--r-- | archaeological_operations/tests.py | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index c9244ca48..b9e1d2e20 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -1585,12 +1585,13 @@ def parcel_post_save(sender, **kwargs): if not kwargs['instance']: return parcel = kwargs['instance'] - cached_label_changed(sender, **kwargs) - updated = False - - if updated: + if not getattr(parcel, '_updated_id', None) \ + and not parcel.operation and not parcel.associated_file \ + and parcel.context_record.count(): + # trying to restore a lost parcel + parcel.operation = parcel.context_record.all()[0].operation parcel.save() return diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index b4c7bc617..d7cf67849 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -2250,8 +2250,9 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): # with no attach the parcel is deleted test_object.assertEqual(operation.parcels.count(), test_object.parcel_number) + # the parcel object is no more automatically deleted test_object.assertEqual(models.Parcel.objects.count(), - test_object.parcel_number) + test_object.parcel_number + 1) self.form_datas[0].extra_tests = [post_first_wizard] self.form_datas[1].extra_tests = [post_second_wizard] |