summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_files/tests.py5
-rw-r--r--archaeological_operations/models.py9
-rw-r--r--archaeological_operations/tests.py3
-rw-r--r--ishtar_common/models.py1
4 files changed, 10 insertions, 8 deletions
diff --git a/archaeological_files/tests.py b/archaeological_files/tests.py
index 7255f677f..9f3693225 100644
--- a/archaeological_files/tests.py
+++ b/archaeological_files/tests.py
@@ -202,8 +202,9 @@ class FileTest(TestCase, FileInit):
fle.parcels.add(parcel)
fle.parcels.clear() # no signal raised... should resave
Parcel.objects.filter(pk=parcel.pk).all()[0].save()
- # our parcel has no operation attached and should be deleted
- self.assertEqual(parcel_nb - 1, Parcel.objects.count())
+ # our parcel has no operation attached and... is no more automatically
+ # deleted
+ self.assertEqual(parcel_nb, Parcel.objects.count())
def test_show(self):
c = Client()
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]
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index b3ce847ce..af63cb7c1 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1176,7 +1176,6 @@ class FullSearch(models.Model):
if hasattr(self, 'data') and self.data:
content_type = ContentType.objects.get_for_model(self)
- datas = []
for json_field in JsonDataField.objects.filter(
content_type=content_type,
search_index=True).all():