]> git.parisson.com Git - telemeta.git/commitdiff
geocode current country names only (not historical names)
authorolivier <>
Wed, 17 Feb 2010 13:34:22 +0000 (13:34 +0000)
committerolivier <>
Wed, 17 Feb 2010 13:34:22 +0000 (13:34 +0000)
telemeta/management/commands/telemeta-geocode.py
telemeta/models/query.py

index 5efe68351604fa54b8f01e7558920f7d2afa3f49..7d7f0603f843f971b8119897691acc3a637e5932 100644 (file)
@@ -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
index fb922ca2e64d5ee56b73fca2ac1c868c902134b7..b0f8433910d43dacb98bf911b30215b4a71fd1ec 100644 (file)
@@ -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):