From: Stephen Finucane Date: Fri, 20 Oct 2017 05:36:53 +0000 (+1100) Subject: REST: Specify default ordering fields X-Git-Tag: v2.1.0-rc1~117 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d65e805be6d99a72df92550ad38a2d1b2005724f;p=thirdparty%2Fpatchwork.git REST: Specify default ordering fields This hides warnings likes the following: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: ]> Signed-off-by: Stephen Finucane [dja: fix merge conflict in patch.py] Signed-off-by: Daniel Axtens Acked-by: Stephen Finucane --- diff --git a/patchwork/api/bundle.py b/patchwork/api/bundle.py index 92899566..0278592a 100644 --- a/patchwork/api/bundle.py +++ b/patchwork/api/bundle.py @@ -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): diff --git a/patchwork/api/check.py b/patchwork/api/check.py index 66b46017..5b381505 100644 --- a/patchwork/api/check.py +++ b/patchwork/api/check.py @@ -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) diff --git a/patchwork/api/cover.py b/patchwork/api/cover.py index 5d829eba..2a7651f4 100644 --- a/patchwork/api/cover.py +++ b/patchwork/api/cover.py @@ -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')\ diff --git a/patchwork/api/event.py b/patchwork/api/event.py index cc9270ae..0d97af22 100644 --- a/patchwork/api/event.py +++ b/patchwork/api/event.py @@ -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') diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py index 1f0ead1f..cb829c7d 100644 --- a/patchwork/api/patch.py +++ b/patchwork/api/patch.py @@ -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 diff --git a/patchwork/api/person.py b/patchwork/api/person.py index d002afff..326c117e 100644 --- a/patchwork/api/person.py +++ b/patchwork/api/person.py @@ -53,6 +53,7 @@ class PersonList(PersonMixin, ListAPIView): search_fields = ('name', 'email') ordering_fields = ('id', 'name', 'email') + ordering = 'id' class PersonDetail(PersonMixin, RetrieveAPIView): diff --git a/patchwork/api/project.py b/patchwork/api/project.py index 11d65049..446c4735 100644 --- a/patchwork/api/project.py +++ b/patchwork/api/project.py @@ -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): diff --git a/patchwork/api/series.py b/patchwork/api/series.py index 12f9277c..b5f4450a 100644 --- a/patchwork/api/series.py +++ b/patchwork/api/series.py @@ -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): diff --git a/patchwork/api/user.py b/patchwork/api/user.py index 32fe836a..1bfad43d 100644 --- a/patchwork/api/user.py +++ b/patchwork/api/user.py @@ -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):