|
@@ -297,36 +297,37 @@ def addInterface(request):
|
|
View_Password = request_dict.get('View_Password', None)
|
|
View_Password = request_dict.get('View_Password', None)
|
|
Type = request_dict.get('Type', None)
|
|
Type = request_dict.get('Type', None)
|
|
ChannelIndex = request_dict.get('ChannelIndex', None)
|
|
ChannelIndex = request_dict.get('ChannelIndex', None)
|
|
- if not all([UID, NickName, View_Account, View_Password, Type, ChannelIndex]):
|
|
|
|
- return response.json(444, {'param': 'UID,NickName,View_Account,View_Password,Type,ChannelIndex'})
|
|
|
|
- tko = TokenObject(token)
|
|
|
|
- response.lang = tko.lang
|
|
|
|
- if tko.code == 0:
|
|
|
|
- userID = tko.userID
|
|
|
|
- re_uid = re.compile(r'^[A-Za-z0-9]{20}$')
|
|
|
|
- if re_uid.match(UID):
|
|
|
|
- is_exist = Device_Info.objects.filter(UID=UID, userID_id=userID)
|
|
|
|
- if is_exist:
|
|
|
|
- return response.json(174)
|
|
|
|
- else:
|
|
|
|
- # is_bind = Device_Info.objects.filter(UID=UID, isShare=False)
|
|
|
|
- # # 判断是否有已绑定用户
|
|
|
|
- # if is_bind:
|
|
|
|
- # return response.json(15)
|
|
|
|
- try:
|
|
|
|
- userDevice = Device_Info(id=CommonService.getUserID(getUser=False), userID_id=userID, UID=UID,
|
|
|
|
- NickName=NickName, View_Account=View_Account,
|
|
|
|
- View_Password=View_Password, Type=Type, ChannelIndex=ChannelIndex)
|
|
|
|
- userDevice.save()
|
|
|
|
- except Exception as e:
|
|
|
|
- return response.json(10, repr(10))
|
|
|
|
|
|
+ if all([UID, NickName, View_Account, View_Password, Type, ChannelIndex]):
|
|
|
|
+ tko = TokenObject(token)
|
|
|
|
+ response.lang = tko.lang
|
|
|
|
+ if tko.code == 0:
|
|
|
|
+ userID = tko.userID
|
|
|
|
+ re_uid = re.compile(r'^[A-Za-z0-9]{20}$')
|
|
|
|
+ if re_uid.match(UID):
|
|
|
|
+ is_exist = Device_Info.objects.filter(UID=UID, userID_id=userID)
|
|
|
|
+ if is_exist:
|
|
|
|
+ return response.json(174)
|
|
else:
|
|
else:
|
|
- return response.json(0)
|
|
|
|
|
|
+ # is_bind = Device_Info.objects.filter(UID=UID, isShare=False)
|
|
|
|
+ # # 判断是否有已绑定用户
|
|
|
|
+ # if is_bind:
|
|
|
|
+ # return response.json(15)
|
|
|
|
+ try:
|
|
|
|
+ userDevice = Device_Info(id=CommonService.getUserID(getUser=False), userID_id=userID, UID=UID,
|
|
|
|
+ NickName=NickName, View_Account=View_Account,
|
|
|
|
+ View_Password=View_Password, Type=Type, ChannelIndex=ChannelIndex)
|
|
|
|
+ userDevice.save()
|
|
|
|
+ except Exception as e:
|
|
|
|
+ return response.json(10, repr(10))
|
|
|
|
+ else:
|
|
|
|
+ return response.json(0)
|
|
|
|
|
|
|
|
+ else:
|
|
|
|
+ return response.json(444, {'param': 'UID'})
|
|
else:
|
|
else:
|
|
- return response.json(444, {'param': 'UID'})
|
|
|
|
|
|
+ return response.json(tko.code)
|
|
else:
|
|
else:
|
|
- return response.json(tko.code)
|
|
|
|
|
|
+ return response.json(444, {'param': 'UID,NickName,View_Account,View_Password,Type,ChannelIndex'})
|
|
|
|
|
|
|
|
|
|
# 新删除设备
|
|
# 新删除设备
|