mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Update django to 5.2
This commit is contained in:
@@ -25,7 +25,7 @@ import time
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import login as auth_login
|
||||
from django.contrib.gis.geoip2 import GeoIP2
|
||||
from django.contrib.gis import geoip2
|
||||
from django.core.cache import cache
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@@ -63,14 +63,20 @@ def get_user_agent_hash(request):
|
||||
_geoip = None
|
||||
|
||||
|
||||
def _get_country(request):
|
||||
def get_geoip() -> geoip2.GeoIP2:
|
||||
# See https://code.djangoproject.com/ticket/36988#ticket
|
||||
global _geoip
|
||||
|
||||
if not _geoip:
|
||||
_geoip = GeoIP2()
|
||||
geoip2.SUPPORTED_DATABASE_TYPES.add("Geoacumen-Country")
|
||||
|
||||
if not _geoip:
|
||||
_geoip = geoip2.GeoIP2()
|
||||
return _geoip
|
||||
|
||||
|
||||
def _get_country(request):
|
||||
try:
|
||||
res = _geoip.country(get_client_ip(request))
|
||||
res = get_geoip().country(get_client_ip(request))
|
||||
except AddressNotFoundError:
|
||||
return None
|
||||
return res['country_code']
|
||||
|
||||
Reference in New Issue
Block a user