Skip to content
Snippets Groups Projects
Commit 04508683 authored by Christophe Simonis's avatar Christophe Simonis
Browse files

[FIX] website: correct GeoIP Legacy compatibility

Attribute is different for country and continent objects.
parent e48767fe
Branches
Tags
No related merge requests found
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment