|
@@ -175,10 +175,7 @@ class EquipmentManagerV3(View):
|
|
|
ip = CommonService.get_ip_address(request)
|
|
|
ipInfo = CommonService.getIpIpInfo(ip, 'CN')
|
|
|
country_qs = CountryModel.objects.filter(country_code=ipInfo['country_code']).values('id')
|
|
|
- if country_qs.exists():
|
|
|
- country = country_qs[0]['id']
|
|
|
- else:
|
|
|
- country = '0'
|
|
|
+ country = country_qs.exists() if country_qs[0]['id'] else 0
|
|
|
region_id = Device_Region().get_device_region(ip)
|
|
|
region_alexa = 'CN' if region_id == 1 else 'ALL'
|
|
|
uid_set_create_dict = {
|
|
@@ -409,6 +406,9 @@ class EquipmentManagerV3(View):
|
|
|
UidSet_id = us_qs.first().id
|
|
|
else:
|
|
|
ip = CommonService.get_ip_address(request)
|
|
|
+ ipInfo = CommonService.getIpIpInfo(ip, 'CN')
|
|
|
+ country_qs = CountryModel.objects.filter(country_code=ipInfo['country_code']).values('id')
|
|
|
+ country = country_qs.exists() if country_qs[0]['id'] else 0
|
|
|
region_id = Device_Region().get_device_region(ip)
|
|
|
region_alexa = 'CN' if region_id == 1 else 'ALL'
|
|
|
uid_set_create_dict = {
|
|
@@ -420,7 +420,8 @@ class EquipmentManagerV3(View):
|
|
|
'nickname': NickName,
|
|
|
'version': version,
|
|
|
'region_alexa': region_alexa,
|
|
|
- 'device_type': is_bind[0]['Type']
|
|
|
+ 'device_type': is_bind[0]['Type'],
|
|
|
+ 'tb_country': country
|
|
|
}
|
|
|
UidSet = UidSetModel.objects.create(**uid_set_create_dict)
|
|
|
UidSet_id = UidSet.id
|
|
@@ -556,16 +557,21 @@ class EquipmentManagerV3(View):
|
|
|
if deviceData.__contains__('NickName'):
|
|
|
us_qs.update(nickname=nickname)
|
|
|
else:
|
|
|
+ ip = CommonService.get_ip_address(request)
|
|
|
+ ipInfo = CommonService.getIpIpInfo(ip, 'CN')
|
|
|
+ country_qs = CountryModel.objects.filter(country_code=ipInfo['country_code']).values('id')
|
|
|
+ country = country_qs.exists() if country_qs[0]['id'] else 0
|
|
|
ChannelIndex = qs[0].ChannelIndex
|
|
|
nowTime = int(time.time())
|
|
|
uid_set_create_dict = {
|
|
|
'uid': uid,
|
|
|
'addTime': nowTime,
|
|
|
'updTime': nowTime,
|
|
|
- # 'ip': CommonService.get_ip_address(request),
|
|
|
+ 'ip': CommonService.get_ip_address(request),
|
|
|
'channel': ChannelIndex,
|
|
|
'nickname': nickname,
|
|
|
- 'device_type': qs[0].Type
|
|
|
+ 'device_type': qs[0].Type,
|
|
|
+ 'tb_country': country
|
|
|
}
|
|
|
UidSetModel.objects.create(**uid_set_create_dict)
|
|
|
di_qs = Device_Info.objects.filter(UID=uid)
|