chenjunkai 6 years ago
parent
commit
218f7d3498
2 changed files with 27 additions and 31 deletions
  1. 2 3
      Controller/CloudVod.py
  2. 25 28
      Controller/EquipmentManager.py

+ 2 - 3
Controller/CloudVod.py

@@ -368,6 +368,7 @@ class CloudVodView(View):
                         ubqs.update(endTime=ctcTime / multiple + addTime)
         # 新增模式
         else:
+            print('craete')
             UID_Bucket.objects.create(
                 uid=UID,
                 channel=channel,
@@ -411,8 +412,6 @@ class CloudVodView(View):
         now_time = int(time.time())
         if now_time > ubqs[0].endTime:
             return response.json(10, '已过期')
-        if not ubqs.exists():
-            return response.json(10, '未购买')
         ubqs.update(status=status)
         utko = UidTokenObject()
         utko.generate(data={'uid': UID, 'channel': channel})
@@ -461,7 +460,7 @@ class CloudVodView(View):
         if not dvqs.exists():
             return response.json(10, '无设备')
         UID = dvqs[0]["UID"]
-        ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel, status=1).values("rank", "channel")
+        ubqs = UID_Bucket.objects.filter(uid=UID, channel=channel).values('status')
         if not ubqs.exists():
             return response.json(10, '设备未购买')
         nowTime = time.time()

+ 25 - 28
Controller/EquipmentManager.py

@@ -1,7 +1,7 @@
 from django.views.decorators.csrf import csrf_exempt
 import traceback
 from Service.ModelService import ModelService
-from Model.models import Device_User, Device_Info,Device_Meal,UID_Bucket
+from Model.models import Device_User, Device_Info, Device_Meal, UID_Bucket
 from Service.CommonService import CommonService
 import simplejson as json
 from Object.TokenObject import TokenObject
@@ -33,7 +33,7 @@ def addNewUserEquipment(userID, deviceContent, response):
                         re_uid = re.compile(r'^[A-Za-z0-9]{20}$')
                         if re_uid.match(UID):
                             # is_bind = Device_Info.objects.filter(UID=UID, isShare=False)
-                            is_bind=''
+                            is_bind = ''
                             # 判断是否有已绑定用户
                             if is_bind:
                                 # return response.json(175)
@@ -106,7 +106,7 @@ def modifyUserEquipment(userID, deviceContent, id, response):
         if deviceValid:
             deviceData = json.loads(deviceContent)
             try:
-                userDevice = Device_Info.objects.filter(userID_id=userID, id=id).update(**deviceData)
+                Device_Info.objects.filter(userID_id=userID, id=id).update(**deviceData)
             except Exception as e:
                 errorInfo = traceback.format_exc()
                 print('修改设备信息错误: %s ' % errorInfo)
@@ -130,18 +130,17 @@ def showAllUserEquipment(userID, response):
         errorInfo = traceback.format_exc()
         print('查询数据库错误: %s' % errorInfo)
         return response.json(500, repr(e))
-
     else:
-        if userValid.exists():
-            # own_permission = ModelService.check_permission(userID=userID,permID=30)
-            if userValid[0].is_superuser != 100 and userValid[0].is_superuser != 1:
-                return response.json(612)
-            else:
-                qs = Device_Info.objects.all()
-                res = CommonService.qs_to_dict(qs)
-                return response.json(0, res)
-        else:
+        if not userValid.exists():
             return response.json(113)
+        own_perm = ModelService.check_permission(userID=userID, permID=30)
+        # if userValid[0].is_superuser != 100 and userValid[0].is_superuser != 1:
+        if own_perm is not True:
+            return response.json(612)
+        qs = Device_Info.objects.all()
+        res = CommonService.qs_to_dict(qs)
+        return response.json(0, res)
+
 
 
 def showAllUserEquipmentPC(userID, fieldDict, response):
@@ -152,21 +151,19 @@ def showAllUserEquipmentPC(userID, fieldDict, response):
         print('查询数据库错误: %s' % errorInfo)
         return response.json(500, repr(e))
     else:
-        if user_valid:
-            own_permission = ModelService.check_permission(userID=userID, permID=30)
-            if own_permission:
-                page = int(fieldDict['page'])
-                line = int(fieldDict['line'])
-                device_info_query_set = Device_Info.objects.all()
-                device_info_count = device_info_query_set.count()
-                device_info_res = device_info_query_set[(page - 1) * line:page * line]
-                sqlDict = CommonService.qs_to_dict(query_set=device_info_res)
-                sqlDict['count'] = device_info_count
-                return response.json(0, sqlDict)
-            else:
-                return response.json(612)
-        else:
+        if not user_valid:
             return response.json(113)
+        own_permission = ModelService.check_permission(userID=userID, permID=30)
+        if not own_permission:
+            return response.json(612)
+        page = int(fieldDict['page'])
+        line = int(fieldDict['line'])
+        device_info_query_set = Device_Info.objects.all()
+        device_info_count = device_info_query_set.count()
+        device_info_res = device_info_query_set[(page - 1) * line:page * line]
+        sqlDict = CommonService.qs_to_dict(query_set=device_info_res)
+        sqlDict['count'] = device_info_count
+        return response.json(0, sqlDict)
 
 
 def findEquipmentInfo(content, type, fieldDict):
@@ -258,7 +255,7 @@ def queryUserEquipmentInterface(request, *callback_args,
                     p['fields']['vod'].append(dm)
             res.append(p)
         print(res)
-        return response.json(0, {'datas':res})
+        return response.json(0, {'datas': res})
     else:
         return response.json(309)