From: olivier <> Date: Wed, 17 Feb 2010 13:34:22 +0000 (+0000) Subject: geocode current country names only (not historical names) X-Git-Tag: 1.1~514 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=41b8c009358f014ce673bba37479921711bb2ea1;p=telemeta.git geocode current country names only (not historical names) --- 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):