express_list maintenance_list 排序

FFIB 3 years ago
parent
commit
e683ad2315

+ 1 - 1
api/express_views.py

@@ -52,7 +52,7 @@ def express_list(request):
52 52
     page = request.POST.get('page', 1)
53 53
     num = request.POST.get('num', 20)
54 54
 
55
-    express = ExpressCompanyInfo.objects.filter(status=True)
55
+    express = ExpressCompanyInfo.objects.filter(status=True).order_by('position')
56 56
     express = [exp.data for exp in express]
57 57
     express, left = pagination(express, page, num)
58 58
 

+ 1 - 0
api/maintenance_views.py

@@ -203,6 +203,7 @@ def maintenance_list(request):
203 203
     if maintenance_status and not maintenance_status == 'all':
204 204
         maintenances = maintenances.filter(maintenance_status=maintenance_status)
205 205
 
206
+    maintenances = maintenances.order_by('-pk')
206 207
     count = maintenances.count()
207 208
     maintenances = [maintenance.data for maintenance in maintenances]
208 209
     maintenances, left = pagination(maintenances, page, num)

+ 20 - 0
maintenance/migrations/0012_expresscompanyinfo_position.py

@@ -0,0 +1,20 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.26 on 2021-09-23 08:09
3
+from __future__ import unicode_literals
4
+
5
+from django.db import migrations, models
6
+
7
+
8
+class Migration(migrations.Migration):
9
+
10
+    dependencies = [
11
+        ('maintenance', '0011_auto_20210922_1727'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AddField(
16
+            model_name='expresscompanyinfo',
17
+            name='position',
18
+            field=models.IntegerField(default=999, help_text='\u6392\u5e8f', verbose_name='position'),
19
+        ),
20
+    ]

+ 1 - 0
maintenance/models.py

@@ -36,6 +36,7 @@ class MaintenacePointInfo(BaseModelMixin):
36 36
 class ExpressCompanyInfo(BaseModelMixin):
37 37
     name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'名称')
38 38
     com = models.CharField(_(u'com'), max_length=255, blank=True, null=True, help_text=u'编码')
39
+    position = models.IntegerField(_(u'position'), default=999, help_text=u'排序')
39 40
 
40 41
     class Meta:
41 42
         verbose_name = _(u'快递公司信息')