From 6b80f7b90c714c335533fa55ba5bf859de717e38 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 27 Oct 2017 09:50:31 +0200 Subject: Command import_geofla_csv: manage town request with year --- ishtar_common/management/commands/import_geofla_csv.py | 5 ++++- ishtar_common/tests.py | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/management/commands/import_geofla_csv.py b/ishtar_common/management/commands/import_geofla_csv.py index 80e10bc81..28c2dabf5 100644 --- a/ishtar_common/management/commands/import_geofla_csv.py +++ b/ishtar_common/management/commands/import_geofla_csv.py @@ -51,7 +51,10 @@ class Command(BaseCommand): q = Town.objects.filter(numero_insee=num_insee) changed, created = False, False if q.count(): - town = q.all()[0] + if q.filter(year=default_year).count(): + town = q.filter(year=default_year).all()[0] + else: + town = q.order_by('-year').all()[0] else: changed = True created = True diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index d882cd85b..2b0a87386 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -115,7 +115,6 @@ class CommandsTestCase(TestCase): self.assertEqual(town_nb + 9, models.Town.objects.count()) - class WizardTestFormData(object): """ Test set to simulate wizard steps -- cgit v1.2.3