Jelajahi Sumber

share info get bug fix

chenjunkai 6 tahun lalu
induk
melakukan
2907a87311
2 mengubah file dengan 16 tambahan dan 25 penghapusan
  1. 0 12
      Controller/DetectController.py
  2. 16 13
      Controller/DeviceShare.py

+ 0 - 12
Controller/DetectController.py

@@ -383,18 +383,6 @@ class NotificationView(View):
         push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
                      "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
         n_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(n_time)))
-        # if lang == 'cn':
-        #     if nickname:
-        #         message_title = "周视({nickname})".format(nickname=nickname)
-        #     else:
-        #         message_title = "周视({uid})".format(uid=uid)
-        #     send_text = '通道:{channel} 日期:{date}'.format(channel=channel, date=n_date)
-        # else:
-        #     if nickname:
-        #         message_title = "zosi({nickname})".format(nickname=nickname)
-        #     else:
-        #         message_title = "zosi({uid})".format(uid=uid)
-        #     send_text = 'channel:{channel} date:{date}'.format(channel=channel, date=n_date)
         if lang == 'cn':
             if nickname:
                 # message_title = "周视({nickname})".format(nickname=nickname)

+ 16 - 13
Controller/DeviceShare.py

@@ -107,20 +107,23 @@ class DeviceShareView(View):
                 UID = data.get('UID', None)
                 sharerDvqs = Device_Info.objects.filter(userID_id=sharer, UID=UID, isShare=False). \
                     values('NickName', 'Type')
-                sharerDuqs = Device_User.objects.filter(userID=sharer).values('username', 'userEmail', 'phone')
-                if sharerDuqs[0]['username']:
-                    share_user = sharerDuqs[0]['username']
-                elif sharerDuqs[0]['userEmail']:
-                    share_user = sharerDuqs[0]['userEmail']
-                elif sharerDuqs[0]['phone']:
-                    share_user = sharerDuqs[0]['phone']
+                if sharerDvqs:
+                    sharerDuqs = Device_User.objects.filter(userID=sharer).values('username', 'userEmail', 'phone')
+                    if sharerDuqs[0]['username']:
+                        share_user = sharerDuqs[0]['username']
+                    elif sharerDuqs[0]['userEmail']:
+                        share_user = sharerDuqs[0]['userEmail']
+                    elif sharerDuqs[0]['phone']:
+                        share_user = sharerDuqs[0]['phone']
+                    else:
+                        share_user = ''
+                    return response.json(0, {
+                        'deviceName': sharerDvqs[0]['NickName'],
+                        'deviceType': sharerDvqs[0]['Type'],
+                        'shareUser': share_user,
+                    })
                 else:
-                    share_user = ''
-                return response.json(0, {
-                    'deviceName': sharerDvqs[0]['NickName'],
-                    'deviceType': sharerDvqs[0]['Type'],
-                    'shareUser': share_user,
-                })
+                    return response.json(173)
             else:
                 return response.json(119)
         else: