diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-06-18 03:17:34 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-06-18 03:17:34 +0200 |
commit | 4be6105527447d6a5f1d6260fdc21132749130a6 (patch) | |
tree | 16a64af860503d1fd4ec601ba658dcaa2c19f536 | |
parent | f803986166528495c727a749bf04d51a513372b2 (diff) | |
parent | 01800a727034607ce1a5b824c6aa28e2920a9aa0 (diff) | |
download | Ishtar-4be6105527447d6a5f1d6260fdc21132749130a6.tar.bz2 Ishtar-4be6105527447d6a5f1d6260fdc21132749130a6.zip |
Merge branch 'stable'
-rw-r--r-- | archaeological_operations/models.py | 3 | ||||
-rw-r--r-- | archaeological_operations/tests.py | 5 | ||||
-rw-r--r-- | archaeological_operations/tests/MCC-parcelles-example.csv | 2 |
3 files changed, 8 insertions, 2 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index d8c16f2d4..bd41384e6 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -755,6 +755,9 @@ def parcel_post_save(sender, **kwargs): if not kwargs['instance']: return parcel = kwargs['instance'] + if not parcel.external_id and (parcel.section or parcel.parcel_number): + parcel.external_id = (parcel.section or "") + (parcel.parcel_number or "") + parcel.save() if parcel.operation and parcel.town not in parcel.operation.towns.all(): parcel.operation.towns.add(parcel.town) if FILES_AVAILABLE and parcel.associated_file and \ diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 73f462895..484e2b259 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -151,7 +151,7 @@ class ImportOperationTest(TestCase): self.assertTrue(current_nb == (old_nb + 2)) # and well imported last_parcels = models.Parcel.objects.order_by('-pk').all()[0:2] - external_ids = sorted(['XXXX', 'YYYY']) + external_ids = sorted(['XXXX', 'YY55']) parcel_numbers = sorted(['42', '55']) sections = sorted(['ZX', 'YY']) self.assertEqual(external_ids, @@ -164,6 +164,9 @@ class ImportOperationTest(TestCase): towns_ope = last_ope.towns.all() for p in last_parcels: self.assertTrue(p.town in towns_ope) + self.assertEqual(models.Parcel.objects.get(parcel_number='55', + section='YY').external_id, + 'YY55') def testParseParcels(self): diff --git a/archaeological_operations/tests/MCC-parcelles-example.csv b/archaeological_operations/tests/MCC-parcelles-example.csv index 1c8d74a2d..f68e98695 100644 --- a/archaeological_operations/tests/MCC-parcelles-example.csv +++ b/archaeological_operations/tests/MCC-parcelles-example.csv @@ -1,3 +1,3 @@ code OA,identifiant parcelle,numero parcelle,section cadastre,annee cadastre,nom commune,numero INSEE commune,nom departement,lieu dit adresse 4200,XXXX,42,ZX,,Paris,75101,Ile-de-France,1 rue de l'Église -4200,YYYY,55,YY,,Lille,59350,Nord,Patis du tertre +4200,,55,YY,,Lille,59350,Nord,Patis du tertre |