[FIX] website: correct GeoIP Legacy compatibility

Attribute is different for country and continent objects.
This commit is contained in:
Christophe Simonis
2018-05-14 19:54:50 +02:00
parent e48767fe65
commit 0450868391
+2 -2
View File
@@ -50,10 +50,10 @@ class GeoIPResolver(object):
# Compatibility with Legacy database.
# Some ips cannot be located to a specific country. Legacy DB used to locate them in
# continent instead of country. Do the same to not change behavior of existing code.
country = r.country if r.country.geoname_id else r.continent
country, attr = (r.country, 'iso_code') if r.country.geoname_id else (r.continent, 'code')
return {
'city': r.city.name,
'country_code': country.iso_code,
'country_code': getattr(country, attr),
'country_name': country.name,
'region': r.subdivisions[0].iso_code if r.subdivisions else None,
'time_zone': r.location.time_zone,