geolocation related fixes

This commit is contained in:
Igor Chubin 2018-11-02 18:12:53 +01:00
parent eed7c3597d
commit a45855fbb4
2 changed files with 8 additions and 4 deletions

View File

@ -116,9 +116,13 @@ def get_location(ip_addr):
Return location pair (CITY, COUNTRY) for `ip_addr`
"""
response = GEOIP_READER.city(ip_addr)
country = response.country.name
city = response.city.name
try:
response = GEOIP_READER.city(ip_addr)
country = response.country.name
city = response.city.name
except geoip2.errors.AddressNotFoundError:
country = None
city = None
#
# temporary disabled it because of geoip services capcacity

View File

@ -72,7 +72,7 @@ def render_location(data):
location (l)
"""
return data['location']
return data['location'].title()
FORMAT_SYMBOL = {
'c': render_condition,