diff options
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] |
