mirror of
https://github.com/nikdoof/vapemap.git
synced 2026-01-30 17:48:24 +00:00
Remove address_string, make full_address cleanout invalid items.
This commit is contained in:
@@ -164,19 +164,11 @@ class Address(models.Model):
|
|||||||
self.address2,
|
self.address2,
|
||||||
self.address3,
|
self.address3,
|
||||||
self.city,
|
self.city,
|
||||||
self.county.name,
|
self.county,
|
||||||
self.postcode,
|
self.postcode,
|
||||||
self.country.name,
|
self.country.name,
|
||||||
]
|
]
|
||||||
return ', '.join([f for f in fields if f])
|
return ', '.join([f.strip() for f in fields if f and f.strip() != ''])
|
||||||
|
|
||||||
@property
|
|
||||||
def address_string(self):
|
|
||||||
return u', '.join([
|
|
||||||
self.address1,
|
|
||||||
self.postcode,
|
|
||||||
unicode(self.country),
|
|
||||||
])
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def geo_location(self):
|
def geo_location(self):
|
||||||
@@ -190,7 +182,7 @@ class Address(models.Model):
|
|||||||
def save(self, **kwargs):
|
def save(self, **kwargs):
|
||||||
no_lookup = kwargs.pop('no_lookup', None)
|
no_lookup = kwargs.pop('no_lookup', None)
|
||||||
if not no_lookup and not self.geo_latitude and not self.geo_longitude:
|
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:
|
if res:
|
||||||
self.geo_latitude, self.geo_longitude = res[1]
|
self.geo_latitude, self.geo_longitude = res[1]
|
||||||
return super(Address, self).save(**kwargs)
|
return super(Address, self).save(**kwargs)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ $(document).ready(function(){initialize_map_store()});
|
|||||||
|
|
||||||
<div id="map-canvas-store" style="width: 300px; height: 300px;" class="map">
|
<div id="map-canvas-store" style="width: 300px; height: 300px;" class="map">
|
||||||
<noscript>
|
<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>
|
</noscript>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user