|
@@ -4,7 +4,7 @@ import traceback
|
|
|
|
|
|
import simplejson as json
|
|
|
from django.utils import timezone
|
|
|
-from Model.models import Device_User,Device_Info, UID_Bucket,UID_App
|
|
|
+from Model.models import Device_User, Device_Info, UID_Bucket, UID_App
|
|
|
from django.db.models import Q
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -344,6 +344,7 @@ def addInterface(request):
|
|
|
else:
|
|
|
return response.json(444, {'param': 'UID,NickName,View_Account,View_Password,Type,ChannelIndex'})
|
|
|
|
|
|
+
|
|
|
# 管理员添加
|
|
|
def admin_addInterface(request):
|
|
|
request.encoding = 'utf-8'
|
|
@@ -425,6 +426,7 @@ def admin_addInterface(request):
|
|
|
sqlDict = CommonService.qs_to_dict([userDevice])
|
|
|
return response.json(0, sqlDict)
|
|
|
|
|
|
+
|
|
|
# 超级管理员修改设备
|
|
|
def admin_modifyInterface(request):
|
|
|
response = ResponseObject()
|
|
@@ -442,7 +444,7 @@ def admin_modifyInterface(request):
|
|
|
if not username:
|
|
|
return response.json(444, 'username')
|
|
|
id = request_dict.get('id', None)
|
|
|
- print (deviceContent)
|
|
|
+ print(deviceContent)
|
|
|
if not deviceContent or not id:
|
|
|
return response.json(444, 'content,id')
|
|
|
tko = TokenObject(token)
|
|
@@ -459,13 +461,13 @@ def admin_modifyInterface(request):
|
|
|
return response.json(404)
|
|
|
|
|
|
deviceData = json.loads(deviceContent)
|
|
|
- print (deviceData['UID'])
|
|
|
+ print(deviceData['UID'])
|
|
|
dValid = Device_Info.objects.filter(userID_id=userID, UID=deviceData['UID'])
|
|
|
if dValid.exists():
|
|
|
dValid_dict = CommonService.qs_to_dict(dValid)
|
|
|
- print (dValid_dict.get('datas')[0].get('pk'))
|
|
|
- if dValid_dict.get('datas')[0].get('pk') == id :
|
|
|
- print ('可以编辑')
|
|
|
+ print(dValid_dict.get('datas')[0].get('pk'))
|
|
|
+ if dValid_dict.get('datas')[0].get('pk') == id:
|
|
|
+ print('可以编辑')
|
|
|
else:
|
|
|
return response.json(174)
|
|
|
# 查询id
|
|
@@ -477,7 +479,7 @@ def admin_modifyInterface(request):
|
|
|
|
|
|
# 更改的时间
|
|
|
update_time = timezone.localtime(timezone.now())
|
|
|
- Device_Info.objects.filter(userID_id=userID, id=id).update(update_time=update_time,**deviceData)
|
|
|
+ Device_Info.objects.filter(userID_id=userID, id=id).update(update_time=update_time, **deviceData)
|
|
|
except Exception as e:
|
|
|
return response.json(177, repr(e))
|
|
|
else:
|
|
@@ -502,6 +504,7 @@ def admin_modifyInterface(request):
|
|
|
res = CommonService.qs_to_dict(qs)
|
|
|
return response.json(0, res)
|
|
|
|
|
|
+
|
|
|
# 新删除设备
|
|
|
def deleteInterface(request):
|
|
|
'''
|
|
@@ -538,7 +541,7 @@ def deleteInterface(request):
|
|
|
# 主用户删除设备
|
|
|
dv_qs.delete()
|
|
|
# 分享获得用户假删除
|
|
|
- ud_dv_qs = Device_Info.objects.filter(UID=uid, isShare=True,primaryUserID=userID)
|
|
|
+ ud_dv_qs = Device_Info.objects.filter(UID=uid, isShare=True, primaryUserID=userID)
|
|
|
if ud_dv_qs.exists():
|
|
|
ud_dv_qs.update(isExist=0)
|
|
|
except Exception as e:
|
|
@@ -597,7 +600,7 @@ def queryInterface(request):
|
|
|
else:
|
|
|
return response.json(tko.code)
|
|
|
|
|
|
-
|
|
|
+
|
|
|
def uid_status(request):
|
|
|
request.encoding = 'utf-8'
|
|
|
response = ResponseObject()
|
|
@@ -614,15 +617,11 @@ def uid_status(request):
|
|
|
if tko.code != 0:
|
|
|
return response.json(tko.code)
|
|
|
if not uid:
|
|
|
- qs = UID_App.objects.filter(userID_id=tko.userID)
|
|
|
- else :
|
|
|
- qs = UID_App.objects.filter(uid=uid)
|
|
|
- res = CommonService.qs_to_dict(qs)
|
|
|
- print (res)
|
|
|
- data=[]
|
|
|
- for uid_app_list in res["datas"]:
|
|
|
- print (uid_app_list.get('fields').get('status'))
|
|
|
- status = uid_app_list.get('fields').get('status')
|
|
|
- uid = uid_app_list.get('fields').get('uid')
|
|
|
- data.append({uid:{ 'status':status ,'cloudVod':{} }})
|
|
|
- return response.json(0, data)
|
|
|
+ qs = UID_App.objects.filter(userID_id=tko.userID).values('uid', 'status')
|
|
|
+ else:
|
|
|
+ qs = UID_App.objects.filter(uid=uid, userID_id=tko.userID).values('uid', 'status')
|
|
|
+ data = {}
|
|
|
+
|
|
|
+ for q in qs:
|
|
|
+ data[q['uid']]= {'push_status': q['status'],'cloudVod':[]}
|
|
|
+ return response.json(0, data)
|