]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
REST: Specify default ordering fields
authorStephen Finucane <stephen@that.guru>
Fri, 20 Oct 2017 05:36:53 +0000 (16:36 +1100)
committerDaniel Axtens <dja@axtens.net>
Sat, 28 Oct 2017 01:39:17 +0000 (12:39 +1100)
This hides warnings likes the following:

    UnorderedObjectListWarning: Pagination may yield inconsistent
    results with an unordered object_list: <QuerySet [<User:
    test_user_0>]>

Signed-off-by: Stephen Finucane <stephen@that.guru>
[dja: fix merge conflict in patch.py]
Signed-off-by: Daniel Axtens <dja@axtens.net>
Acked-by: Stephen Finucane <stephen@that.guru>
patchwork/api/bundle.py
patchwork/api/check.py
patchwork/api/cover.py
patchwork/api/event.py
patchwork/api/patch.py
patchwork/api/person.py
patchwork/api/project.py
patchwork/api/series.py
patchwork/api/user.py

index 92899566365e0ef40123a964ac77cec297282bd4..0278592a9e34c26dd1b615bc74875cc1331c4b9e 100644 (file)
@@ -76,6 +76,7 @@ class BundleList(BundleMixin, ListAPIView):
     filter_class = BundleFilter
     search_fields = ('name',)
     ordering_fields = ('id', 'name', 'owner')
+    ordering = 'id'
 
 
 class BundleDetail(BundleMixin, RetrieveAPIView):
index 66b460174e87270f3af59c295891a80062f132ca..5b3815050664f516fad538c2cd7c1797eb705b13 100644 (file)
@@ -81,6 +81,7 @@ class CheckListCreate(CheckMixin, ListCreateAPIView):
     """List or create checks."""
 
     lookup_url_kwarg = 'patch_id'
+    ordering = 'id'
 
     def create(self, request, patch_id, *args, **kwargs):
         p = Patch.objects.get(id=patch_id)
index 5d829eba2f07b02d4e4192bd59fe289af83befa9..2a7651f488aef75f2b4f3519485ff21ae393a174 100644 (file)
@@ -75,6 +75,7 @@ class CoverLetterList(ListAPIView):
     filter_class = CoverLetterFilter
     search_fields = ('name',)
     ordering_fields = ('id', 'name', 'date', 'submitter')
+    ordering = 'id'
 
     def get_queryset(self):
         qs = CoverLetter.objects.all().prefetch_related('series')\
index cc9270ae2ac94b2f8b8c355361cd74ed24ae57dc..0d97af227f0e6f1c245b9d36a8ad73b8a93f6ef1 100644 (file)
@@ -91,13 +91,12 @@ class EventList(ListAPIView):
     serializer_class = EventSerializer
     filter_class = EventFilter
     page_size_query_param = None  # fixed page size
-    ordering = '-date'
     ordering_fields = ()
+    ordering = '-date'
 
     def get_queryset(self):
         return Event.objects.all()\
             .select_related('project', 'patch', 'series', 'cover',
                             'previous_state', 'current_state',
                             'previous_delegate', 'current_delegate',
-                            'created_check')\
-            .order_by('-date')
+                            'created_check')
index 1f0ead1f799a762b43654348ec7e6dc067bc123c..cb829c7db5d74228d41da8dadc7f579f8aa2fe15 100644 (file)
@@ -148,6 +148,7 @@ class PatchList(ListAPIView):
     search_fields = ('name',)
     ordering_fields = ('id', 'name', 'project', 'date', 'state', 'archived',
                        'submitter', 'check')
+    ordering = 'id'
 
     def get_queryset(self):
         # TODO(stephenfin): Does the defer here cause issues with Django 1.6
index d002afff5d9f9b9b82bbea1064a927e492324935..326c117e2cf84fa32f18d567b2f04932820b8348 100644 (file)
@@ -53,6 +53,7 @@ class PersonList(PersonMixin, ListAPIView):
 
     search_fields = ('name', 'email')
     ordering_fields = ('id', 'name', 'email')
+    ordering = 'id'
 
 
 class PersonDetail(PersonMixin, RetrieveAPIView):
index 11d65049140dd2326c1d54ab8dffe23e1caa22fe..446c47356951392301482717209970e2a90055e6 100644 (file)
@@ -79,6 +79,7 @@ class ProjectList(ProjectMixin, ListAPIView):
     search_fields = ('link_name', 'list_id', 'list_email', 'web_url',
                      'scm_url', 'webscm_url')
     ordering_fields = ('id', 'name', 'link_name', 'list_id')
+    ordering = 'id'
 
 
 class ProjectDetail(ProjectMixin, RetrieveUpdateAPIView):
index 12f9277c882cb69acf16adc109f48bbfc8206c1a..b5f4450a71b00cf4c914b795162247ff273fc368 100644 (file)
@@ -71,6 +71,7 @@ class SeriesList(SeriesMixin, ListAPIView):
     filter_class = SeriesFilter
     search_fields = ('name',)
     ordering_fields = ('id', 'name', 'date', 'submitter', 'received_all')
+    ordering = 'id'
 
 
 class SeriesDetail(SeriesMixin, RetrieveAPIView):
index 32fe836ac826ff4f0b0b1706aed147cc50711562..1bfad43d6a9c6891dc295117bd1933288453de0e 100644 (file)
@@ -58,6 +58,7 @@ class UserList(UserMixin, ListAPIView):
 
     search_fields = ('username', 'first_name', 'last_name', 'email')
     ordering_fields = ('id', 'username', 'email')
+    ordering = 'id'
 
 
 class UserDetail(UserMixin, RetrieveUpdateAPIView):