|
@@ -78,13 +78,19 @@ class DetectControllerView(View):
|
|
|
uid = request_dict.get('uid', None)
|
|
|
if uid:
|
|
|
qs = qs.filter(devUid=uid)
|
|
|
+ dvqs = Device_Info.objects.filter(UID=uid).values('Type')
|
|
|
+ uid_type_dict = {uid: dvqs[0]['Type']}
|
|
|
+ else:
|
|
|
+ dvqs = Device_Info.objects.filter(userID_id=userID).values('UID','Type')
|
|
|
+ uid_type_dict = {}
|
|
|
+ for dv in dvqs:
|
|
|
+ uid_type_dict[dv['UID']] = dv['Type']
|
|
|
if not qs.exists():
|
|
|
return response.json(0, {'datas': [], 'count': 0})
|
|
|
qs = qs.values('id', 'devUid', 'devNickName', 'Channel', 'eventType', 'status', 'alarm', 'eventTime',
|
|
|
'receiveTime', 'is_st')
|
|
|
count = qs.count()
|
|
|
qr = qs[(page - 1) * line:page * line]
|
|
|
- # send_json = CommonService.qs_to_dict(res)
|
|
|
res = []
|
|
|
import oss2
|
|
|
auth = oss2.Auth('LTAIyMkGfEdogyL9', '71uIjpsqVOmF7DAITRyRuc259jHOjO')
|
|
@@ -94,6 +100,7 @@ class DetectControllerView(View):
|
|
|
p['img'] = bucket.sign_url('GET',
|
|
|
'{uid}/{channel}/{time}.jpeg'.format(uid=p['devUid'], channel=p['Channel'],
|
|
|
time=p['eventTime']), 300)
|
|
|
+ p['uid_type'] = uid_type_dict[p['devUid']]
|
|
|
res.append(p)
|
|
|
return response.json(0, {'datas': res, 'count': count})
|
|
|
|
|
@@ -279,7 +286,7 @@ class NotificationView(View):
|
|
|
# push.audience = jpush.all_
|
|
|
push.audience = jpush.registration_id(token_val)
|
|
|
push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
|
|
|
- "received_at": n_time, "sound": "sound.aif", "uid": uid,"zpush":"1"}
|
|
|
+ "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1"}
|
|
|
push_msg = json.dumps(push_data)
|
|
|
# push.notification = jpush.notification(alert="hello jpush api")
|
|
|
# push.notification = jpush.notification(alert=push_msg)
|
|
@@ -315,7 +322,7 @@ class NotificationView(View):
|
|
|
serverKey = gcm_config[appBundleId]
|
|
|
event_type = request_dict.get('event_type', None)
|
|
|
push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
|
|
|
- "received_at": n_time, "sound": "sound.aif", "uid": uid,"zpush":"1"}
|
|
|
+ "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1"}
|
|
|
json_data = {
|
|
|
"collapse_key": "WhatYouWant",
|
|
|
"data": push_data,
|