chenjunkai %!s(int64=6) %!d(string=hai) anos
pai
achega
790ca7fcca
Modificáronse 2 ficheiros con 11 adicións e 4 borrados
  1. 10 3
      Controller/DetectController.py
  2. 1 1
      Object/TokenObject.py

+ 10 - 3
Controller/DetectController.py

@@ -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,

+ 1 - 1
Object/TokenObject.py

@@ -21,7 +21,7 @@ class TokenObject:
 
     def __init__(self, token=None):
         if token == 'local':
-            token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySUQiOiIxNTQzOTA5MDUwNDEzMTM4MDAxMzgwMDAiLCJsYW5nIjoiZW4iLCJ1c2VyIjoiMTM4MDAxMzgwMDEiLCJtX2NvZGUiOiIxMjM0MTMyNDMyMTQiLCJleHAiOjE1NTU5MDQ5MjF9.LG-wlg7ttQOI66QoEFD7CWaO5XwwZNaujceLgiMGxts'
+            token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NTg3NzU5MDcsInVzZXIiOiIxMzgwMDEzODAwMSIsInVzZXJJRCI6IjE1MTU2NDI2MjMzNzkzOTUxMzgwMDEzODAwMSIsImxhbmciOiJlbiIsIm1fY29kZSI6IjEyMzQxMzI0MzIxNCJ9.6OZMsGUpzhtRZSIpONaZaueqss787RBLC6w_Toe-3RI'
         if token == 'test':
             token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiMTM4MDAxMzgwMDEiLCJ1c2VySUQiOiIxNTE1NjQyNjIzMzc5Mzk1MTM4MDAxMzgwMDEiLCJsYW5nIjoiZW4iLCJleHAiOjE1NTI2MTIxOTF9.sO8BtSclN6B-qwqNmYWbICatHYEtyMdoqzZ0hcOSsmg'
         self.token = token