|
@@ -45,18 +45,12 @@ class ConfirmRegion(View):
|
|
return response.json(0, {'request_api_url': api, 'push_api_url': push_api})
|
|
return response.json(0, {'request_api_url': api, 'push_api_url': push_api})
|
|
|
|
|
|
# 不存在则返回美洲域名
|
|
# 不存在则返回美洲域名
|
|
- region_qs = RegionModel.objects.filter(continent_code='NA').values('api', 'push_api')
|
|
|
|
- api = region_qs[0]['api']
|
|
|
|
- push_api = region_qs[0]['push_api']
|
|
|
|
-
|
|
|
|
|
|
+ api, push_api, region_id = get_default_api()
|
|
if not device_domain_qs.exists():
|
|
if not device_domain_qs.exists():
|
|
DeviceDomainModel.objects.create(ip=ip, country_name='NA', api=api)
|
|
DeviceDomainModel.objects.create(ip=ip, country_name='NA', api=api)
|
|
-
|
|
|
|
return response.json(0, {'request_api_url': api, 'push_api_url': push_api})
|
|
return response.json(0, {'request_api_url': api, 'push_api_url': push_api})
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- print(e)
|
|
|
|
- return response.json(0, {'request_api_url': 'https://www.dvema.com',
|
|
|
|
- 'push_api_url': 'https://push.dvema.com'})
|
|
|
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
|
|
|
|
class ConfirmRegionV2(View):
|
|
class ConfirmRegionV2(View):
|
|
@@ -65,7 +59,8 @@ class ConfirmRegionV2(View):
|
|
def dispatch(self, *args, **kwargs):
|
|
def dispatch(self, *args, **kwargs):
|
|
return super(ConfirmRegionV2, self).dispatch(*args, **kwargs)
|
|
return super(ConfirmRegionV2, self).dispatch(*args, **kwargs)
|
|
|
|
|
|
- def get(self, request, *args, **kwargs):
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def get(request, *args, **kwargs):
|
|
response = ResponseObject()
|
|
response = ResponseObject()
|
|
serial_number = request.GET.get('serial_number', None)
|
|
serial_number = request.GET.get('serial_number', None)
|
|
if not serial_number:
|
|
if not serial_number:
|
|
@@ -98,11 +93,11 @@ class ConfirmRegionV2(View):
|
|
else:
|
|
else:
|
|
# 返回美洲域名
|
|
# 返回美洲域名
|
|
data_dict['country_code'] = 'NA'
|
|
data_dict['country_code'] = 'NA'
|
|
- api, push_api, region_id = self.get_default_api()
|
|
|
|
|
|
+ api, push_api, region_id = get_default_api()
|
|
else:
|
|
else:
|
|
# 返回美洲域名
|
|
# 返回美洲域名
|
|
data_dict['country_code'] = 'NA'
|
|
data_dict['country_code'] = 'NA'
|
|
- api, push_api, region_id = self.get_default_api()
|
|
|
|
|
|
+ api, push_api, region_id = get_default_api()
|
|
|
|
|
|
# 更新或创建设备域名数据
|
|
# 更新或创建设备域名数据
|
|
data_dict['region_id'] = region_id
|
|
data_dict['region_id'] = region_id
|
|
@@ -119,23 +114,16 @@ class ConfirmRegionV2(View):
|
|
}
|
|
}
|
|
return response.json(0, res)
|
|
return response.json(0, res)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- print(repr(e))
|
|
|
|
- api, push_api, region_id = self.get_default_api()
|
|
|
|
- res = {
|
|
|
|
- 'request_api_url': api,
|
|
|
|
- 'push_api_url': push_api,
|
|
|
|
- 'region_id': region_id
|
|
|
|
- }
|
|
|
|
- return response.json(0, res)
|
|
|
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
- # 获取区域表美洲的相关数据
|
|
|
|
- @staticmethod
|
|
|
|
- def get_default_api():
|
|
|
|
- region_qs = RegionModel.objects.filter(continent_code='NA').values('api', 'push_api', 'id')
|
|
|
|
- api = region_qs[0]['api']
|
|
|
|
- push_api = region_qs[0]['push_api']
|
|
|
|
- region_id = region_qs[0]['id']
|
|
|
|
- return api, push_api, region_id
|
|
|
|
|
|
+
|
|
|
|
+def get_default_api():
|
|
|
|
+ # 获取默认域名(美洲服域名)
|
|
|
|
+ region_qs = RegionModel.objects.filter(continent_code='NA').values('api', 'push_api', 'id')
|
|
|
|
+ api = region_qs[0]['api']
|
|
|
|
+ push_api = region_qs[0]['push_api']
|
|
|
|
+ region_id = region_qs[0]['id']
|
|
|
|
+ return api, push_api, region_id
|
|
|
|
|
|
|
|
|
|
class Device_Region(object):
|
|
class Device_Region(object):
|