From 705ef6cfebe000df1971e25ee269c2e26bac18f4 Mon Sep 17 00:00:00 2001 From: Chris Adkins Date: Tue, 7 May 2019 21:31:44 +1000 Subject: [PATCH] Fixed #30447 -- Added 'is_in_european_union' in GeoIP2.city() dict. --- django/contrib/gis/geoip2/resources.py | 1 + docs/ref/contrib/gis/geoip2.txt | 1 + tests/gis_tests/test_geoip2.py | 1 + 3 files changed, 3 insertions(+) diff --git a/django/contrib/gis/geoip2/resources.py b/django/contrib/gis/geoip2/resources.py index 3de3346194..08923b0998 100644 --- a/django/contrib/gis/geoip2/resources.py +++ b/django/contrib/gis/geoip2/resources.py @@ -6,6 +6,7 @@ def City(response): 'country_code': response.country.iso_code, 'country_name': response.country.name, 'dma_code': response.location.metro_code, + 'is_in_european_union': response.country.is_in_european_union, 'latitude': response.location.latitude, 'longitude': response.location.longitude, 'postal_code': response.postal.code, diff --git a/docs/ref/contrib/gis/geoip2.txt b/docs/ref/contrib/gis/geoip2.txt index 91e2c793b1..2dc3dff526 100644 --- a/docs/ref/contrib/gis/geoip2.txt +++ b/docs/ref/contrib/gis/geoip2.txt @@ -38,6 +38,7 @@ Here is an example of its usage:: 'country_code': 'US', 'country_name': 'United States', 'dma_code': 807, + 'is_in_european_union': False, 'latitude': 37.419200897216797, 'longitude': -122.05740356445312, 'postal_code': '94043', diff --git a/tests/gis_tests/test_geoip2.py b/tests/gis_tests/test_geoip2.py index 9813f384ed..6993db3c76 100644 --- a/tests/gis_tests/test_geoip2.py +++ b/tests/gis_tests/test_geoip2.py @@ -127,6 +127,7 @@ class GeoIPTest(SimpleTestCase): self.assertEqual('Houston', d['city']) self.assertEqual('TX', d['region']) self.assertEqual('America/Chicago', d['time_zone']) + self.assertFalse(d['is_in_european_union']) geom = g.geos(query) self.assertIsInstance(geom, GEOSGeometry)