diff options
| author | Étienne Loks <etienne.loks@proxience.com> | 2015-06-18 05:08:23 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@proxience.com> | 2015-06-18 05:08:23 +0200 | 
| commit | 4c56faeaeda75e952b410465aefb0534549dfc95 (patch) | |
| tree | 6b994cd556762e5c8ca82059f6805a396bb6822b | |
| parent | 1dd34cabdccaec51c2b7b06099c66a068ff58aae (diff) | |
| download | Ishtar-4c56faeaeda75e952b410465aefb0534549dfc95.tar.bz2 Ishtar-4c56faeaeda75e952b410465aefb0534549dfc95.zip | |
Import: really delete associated object when deleting an import
| -rw-r--r-- | archaeological_operations/tests.py | 4 | ||||
| -rw-r--r-- | ishtar_common/models.py | 3 | 
2 files changed, 4 insertions, 3 deletions
| diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index bbe92b3c8..9abc62bd4 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -170,6 +170,10 @@ class ImportOperationTest(TestCase):          self.assertEqual(models.Parcel.objects.get(parcel_number='55',                                                     section='YY').external_id,                          'YY55') +        # delete associated parcel with the import deletion +        parcel_count = models.Parcel.objects.count() +        impt.delete() +        self.assertEqual(parcel_count-2, models.Parcel.objects.count())      def testParseParcels(self): diff --git a/ishtar_common/models.py b/ishtar_common/models.py index c1ee90df6..a82638396 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1490,9 +1490,6 @@ def pre_delete_import(sender, **kwargs):          return      to_delete = []      for accessor, imported in instance.get_all_imported(): -        # if imported is related to another import do not delete -        if getattr(instance, accessor).exclude(pk=imported.pk).count(): -            continue          to_delete.append(imported)      for item in to_delete:          item.delete() | 
