Example #1
0
 def test_get_geoip_country(self):
     """Test that the client instantiates
     """
     gi_country = get_geoip_country()
     self.assertIsNotNone(gi_country)
     country = gi_country.country_code_by_addr('8.8.8.8')
     self.assertEqual('US', country)
Example #2
0
 def test_get_geoip_country(self):
     """Test that the client instantiates
     """
     gi_country = get_geoip_country()
     self.assertIsNotNone(gi_country)
     country = gi_country.country_code_by_addr('8.8.8.8')
     self.assertEqual('US', country)
Example #3
0
 def update_locale_info_by_ip_from_request(self, request):
     """Update user info by IP Address
     
     Store last_login_ip only when logging in
     Store country resolved from IP
     Store timezone resolved from IP
     
     Caller: api.auth.decorators.register_or_login_user
     
     Unknown whether this code throws an exception, but catch it upstream if any
     """
     try:
         ip = extract_request_ip(request)
         if ip and self.last_login_ip != ip:
             self.last_login_ip = ip
             gi_country = get_geoip_country()
             gi_city = get_geoip_city()
             self.detected_country = gi_country.country_code_by_addr(ip)
             self.detected_timezone = gi_city.time_zone_by_addr(ip)
             self.save()
     except:
         # couldn't find geoip records for ip, just be quiet for now
         #rollbar.report_exc_info(request=request)
         pass