Remove address_string, make full_address cleanout invalid items.

This commit is contained in:
2013-04-06 22:18:40 +01:00
parent ace2e9b48b
commit e0ba49494e
2 changed files with 5 additions and 13 deletions

View File

@@ -164,19 +164,11 @@ class Address(models.Model):
self.address2,
self.address3,
self.city,
self.county.name,
self.county,
self.postcode,
self.country.name,
]
return ', '.join([f for f in fields if f])
@property
def address_string(self):
return u', '.join([
self.address1,
self.postcode,
unicode(self.country),
])
]
return ', '.join([f.strip() for f in fields if f and f.strip() != ''])
@property
def geo_location(self):
@@ -190,7 +182,7 @@ class Address(models.Model):
def save(self, **kwargs):
no_lookup = kwargs.pop('no_lookup', None)
if not no_lookup and not self.geo_latitude and not self.geo_longitude:
res = caching_geo_lookup(self.address_string)
res = caching_geo_lookup(self.full_address)
if res:
self.geo_latitude, self.geo_longitude = res[1]
return super(Address, self).save(**kwargs)

View File

@@ -104,7 +104,7 @@ $(document).ready(function(){initialize_map_store()});
<div id="map-canvas-store" style="width: 300px; height: 300px;" class="map">
<noscript>
<img alt="Map of {{ store.address.address_string }}" src="https://maps.google.com/maps/api/staticmap?center={{ store.address.geo_latitude }},{{ store.address.geo_longitude }}&zoom=16&markers={{ store.address.geo_latitude }},{{ store.address.geo_longitude }}&size=300x300&sensor=false">
<img alt="Map of {{ store.address.full_address }}" src="https://maps.google.com/maps/api/staticmap?center={{ store.address.geo_latitude }},{{ store.address.geo_longitude }}&zoom=16&markers={{ store.address.geo_latitude }},{{ store.address.geo_longitude }}&size=300x300&sensor=false">
</noscript>
</div>
</div>