From 41b8c009358f014ce673bba37479921711bb2ea1 Mon Sep 17 00:00:00 2001 From: olivier <> Date: Wed, 17 Feb 2010 13:34:22 +0000 Subject: [PATCH] geocode current country names only (not historical names) --- telemeta/management/commands/telemeta-geocode.py | 2 +- telemeta/models/query.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/telemeta/management/commands/telemeta-geocode.py b/telemeta/management/commands/telemeta-geocode.py index 5efe6835..7d7f0603 100644 --- a/telemeta/management/commands/telemeta-geocode.py +++ b/telemeta/management/commands/telemeta-geocode.py @@ -20,7 +20,7 @@ class Command(BaseCommand): except IOError: raise CommandError("Unable to open %s" % datafile) - locations = [l for l in Location.objects.filter(type=Location.COUNTRY)] + locations = [l for l in Location.objects.all().current().filter(type=Location.COUNTRY)] i = 0 geocoded = 0 diff --git a/telemeta/models/query.py b/telemeta/models/query.py index fb922ca2..b0f84339 100644 --- a/telemeta/models/query.py +++ b/telemeta/models/query.py @@ -351,6 +351,14 @@ class LocationQuerySet(CoreQuerySet): self.__class__.__flatname_map = map return map + def current(self, is_current=True): + if is_current: + where = ["locations.id = locations.current_location_id"] + else: + where = ["locations.id <> locations.current_location_id"] + + return self.extra(where = where); + class LocationManager(CoreManager): def get_query_set(self): -- 2.39.5