diff options
author | Stephen Finucane <stephen@that.guru> | 2017-10-20 16:36:53 +1100 |
---|---|---|
committer | Daniel Axtens <dja@axtens.net> | 2017-10-28 12:39:17 +1100 |
commit | d65e805be6d99a72df92550ad38a2d1b2005724f (patch) | |
tree | c09343577d629838a836d0c9249e816548a9a8ed | |
parent | 9527ae40ef9ce1867524ec9eda0c40b1c6c493a9 (diff) | |
download | patchwork-d65e805be6d99a72df92550ad38a2d1b2005724f.tar patchwork-d65e805be6d99a72df92550ad38a2d1b2005724f.tar.gz |
REST: Specify default ordering fields
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>
-rw-r--r-- | patchwork/api/bundle.py | 1 | ||||
-rw-r--r-- | patchwork/api/check.py | 1 | ||||
-rw-r--r-- | patchwork/api/cover.py | 1 | ||||
-rw-r--r-- | patchwork/api/event.py | 5 | ||||
-rw-r--r-- | patchwork/api/patch.py | 1 | ||||
-rw-r--r-- | patchwork/api/person.py | 1 | ||||
-rw-r--r-- | patchwork/api/project.py | 1 | ||||
-rw-r--r-- | patchwork/api/series.py | 1 | ||||
-rw-r--r-- | patchwork/api/user.py | 1 |
9 files changed, 10 insertions, 3 deletions
diff --git a/patchwork/api/bundle.py b/patchwork/api/bundle.py index 9289956..0278592 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 66b4601..5b38150 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 5d829eb..2a7651f 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 cc9270a..0d97af2 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 1f0ead1..cb829c7 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 d002aff..326c117 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 11d6504..446c473 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 12f9277..b5f4450 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 32fe836..1bfad43 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): |