Beispiel #1
0
 def from_postal_code(cls, postal_code):
     """
     Geolocation user from postal code. This is useful
     for search using postal code.
     """
     lat, lon = geolocation.geolocate("%s France" % postal_code)  # FIXME: this will obviously only work in France
     return cls(lat=lat, lon=lon)
Beispiel #2
0
    def geolocate(self, address):
        """
        Geolocate a geolocation object, given an address.

        :param address:         the address to geolocate
        """
        try:
            lat, lon = geolocation.geolocate(address)
        except errors.GeolocationError:
            self.has_error = True
            self.lat = None
            self.lon = None
        else:
            self.has_error = False
            self.lat = lat
            self.lon = lon

        self.save()