Fix failing geoip searching on the homepage for unauthenticated users
This commit is contained in:
parent
e647984e4a
commit
d8e9f70793
1 changed files with 3 additions and 2 deletions
|
@ -77,11 +77,12 @@ def home(request, *args, **kwards):
|
||||||
else:
|
else:
|
||||||
city = sorted(nearby_cities, key=lambda city: location.city_distance_from(ll, city))[0]
|
city = sorted(nearby_cities, key=lambda city: location.city_distance_from(ll, city))[0]
|
||||||
|
|
||||||
if request.user.profile.city is None:
|
if request.user.is_authenticated and request.user.profile.city is None:
|
||||||
profile = request.user.profile
|
profile = request.user.profile
|
||||||
profile.city = city
|
profile.city = city
|
||||||
profile.save()
|
profile.save()
|
||||||
except:
|
except Exception as err:
|
||||||
|
print("City lookup failed", err)
|
||||||
raise Exception('City lookup filed')
|
raise Exception('City lookup filed')
|
||||||
else:
|
else:
|
||||||
raise Exception('Geocoder result has no latlng')
|
raise Exception('Geocoder result has no latlng')
|
||||||
|
|
Loading…
Reference in a new issue