Browse Source

对FAQ进行desc排序

tanghongbin 5 years ago
parent
commit
a83e46f7f0
2 changed files with 7 additions and 3 deletions
  1. 5 1
      Controller/AdminManage.py
  2. 2 2
      Controller/FAQController.py

+ 5 - 1
Controller/AdminManage.py

@@ -335,7 +335,11 @@ class AdminManage(TemplateView):
         data = type_data['data']
         quantity = 0
         for di in di_qs:
-            di['Type'] = DEVICE_TYPE[di['Type']]
+            if DEVICE_TYPE.__contains__(di['Type']):
+                device_model = DEVICE_TYPE[di['Type']]
+            else:
+                device_model = DEVICE_TYPE[0]
+            di['Type'] = device_model
             quantity += di['quantity']
             data.append(di)
         type_data['quantity'] = quantity

+ 2 - 2
Controller/FAQController.py

@@ -238,13 +238,13 @@ class FAQView(View):
                 own_permission = ModelService.check_perm(userID=userID, permID=110)
                 if own_permission is not True:
                     return response.json(404)
-                faq_qs = FAQModel.objects.filter(title__contains=search_key)
+                faq_qs = FAQModel.objects.filter(title__contains=search_key).order_by('-add_time')
             else:
                 own_permission = ModelService.check_perm(userID=userID, permID=100)
                 if own_permission is not True:
                     return response.json(404)
 
-                faq_qs = FAQModel.objects.filter()
+                faq_qs = FAQModel.objects.filter().order_by('-add_time')
 
             if not faq_qs.exists():
                 return response.json(0, {'count': 0, 'data': []})