|
@@ -3638,4 +3638,26 @@ def delete_local_account(username):
|
|
|
user = user_qs[0]
|
|
|
if user.is_local:
|
|
|
user.delete()
|
|
|
- Device_Info.objects.filter(userID__userID=user.userID).delete()
|
|
|
+ Device_Info.objects.filter(userID__userID=user.userID).delete()
|
|
|
+
|
|
|
+
|
|
|
+def updateUserCountry(request):
|
|
|
+ country_ip_qs = CountryIPModel.objects.filter()
|
|
|
+ if country_ip_qs.exists():
|
|
|
+ country_ip_qs = country_ip_qs[0: 1000]
|
|
|
+ ids = []
|
|
|
+ redisObject = RedisObject(db=6)
|
|
|
+ for country_ip in country_ip_qs:
|
|
|
+ key = 'ip_country_{ip}'.format(ip=country_ip.ip)
|
|
|
+ data = redisObject.get_data(key=key)
|
|
|
+ if data:
|
|
|
+ country = data
|
|
|
+ else:
|
|
|
+ country = CommonService.getAddr(country_ip.ip)
|
|
|
+ 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)
|
|
|
+ CountryIPModel.objects.filter(id__in=tuple(ids)).delete()
|
|
|
+ response = ResponseObject()
|
|
|
+ return response.json(0)
|