|
@@ -3646,20 +3646,20 @@ def delete_local_account(username):
|
|
def updateUserCountry(request):
|
|
def updateUserCountry(request):
|
|
country_ip_qs = CountryIPModel.objects.filter()
|
|
country_ip_qs = CountryIPModel.objects.filter()
|
|
if country_ip_qs.exists():
|
|
if country_ip_qs.exists():
|
|
- country_ip_qs = country_ip_qs[0: 100]
|
|
|
|
|
|
+ country_ip_qs = country_ip_qs[0: 100].values()
|
|
ids = []
|
|
ids = []
|
|
redisObject = RedisObject(db=6)
|
|
redisObject = RedisObject(db=6)
|
|
for country_ip in country_ip_qs:
|
|
for country_ip in country_ip_qs:
|
|
- key = 'ip_country_{ip}'.format(ip=country_ip.ip)
|
|
|
|
|
|
+ key = 'ip_country_{ip}'.format(ip=country_ip['ip'])
|
|
data = redisObject.get_data(key=key)
|
|
data = redisObject.get_data(key=key)
|
|
if data:
|
|
if data:
|
|
country = data
|
|
country = data
|
|
else:
|
|
else:
|
|
- country = CommonService.getAddr(country_ip.ip)
|
|
|
|
|
|
+ country = CommonService.getAddr(country_ip['ip'])
|
|
redisObject.set_data(key=key, val=country, expire=3600)
|
|
redisObject.set_data(key=key, val=country, expire=3600)
|
|
|
|
|
|
- UserExModel.objects.filter(id=country_ip.user_ex_id).update(country=country)
|
|
|
|
- ids.append(country_ip.id)
|
|
|
|
|
|
+ UserExModel.objects.filter(id=country_ip['user_ex_id']).update(country=country)
|
|
|
|
+ ids.append(country_ip['id'])
|
|
CountryIPModel.objects.filter(id__in=tuple(ids)).delete()
|
|
CountryIPModel.objects.filter(id__in=tuple(ids)).delete()
|
|
response = ResponseObject()
|
|
response = ResponseObject()
|
|
return response.json(0)
|
|
return response.json(0)
|