[FIX] website: correct GeoIP Legacy compatibility
Attribute is different for country and continent objects.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user