From: Stephen Finucane Date: Fri, 30 Dec 2016 12:14:19 +0000 (+0000) Subject: REST: Integrate ordering X-Git-Tag: v2.0.0-rc1~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e1be80a8d025e292e9f3707ed2591125547d7fb;p=thirdparty%2Fpatchwork.git REST: Integrate ordering Order by way of the 'order' parameter on many endpoints. Signed-off-by: Stephen Finucane --- diff --git a/patchwork/api/cover.py b/patchwork/api/cover.py index 0b6b546c..8b8d47b1 100644 --- a/patchwork/api/cover.py +++ b/patchwork/api/cover.py @@ -69,6 +69,7 @@ class CoverLetterList(ListAPIView): serializer_class = CoverLetterListSerializer filter_class = CoverLetterFilter search_fields = ('name',) + ordering_fields = ('id', 'name', 'date', 'submitter') def get_queryset(self): qs = CoverLetter.objects.all().prefetch_related('series')\ diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py index fc5a0ee1..e8fb0ef3 100644 --- a/patchwork/api/patch.py +++ b/patchwork/api/patch.py @@ -120,6 +120,8 @@ class PatchList(ListAPIView): serializer_class = PatchListSerializer filter_class = PatchFilter search_fields = ('name',) + ordering_fields = ('id', 'name', 'project', 'date', 'state', 'archived', + 'submitter', 'check') def get_queryset(self): return Patch.objects.all().with_tag_counts()\ diff --git a/patchwork/api/person.py b/patchwork/api/person.py index 10cf781c..7947f825 100644 --- a/patchwork/api/person.py +++ b/patchwork/api/person.py @@ -47,6 +47,7 @@ class PersonList(PersonMixin, ListAPIView): """List users.""" search_fields = ('name', 'email') + ordering_fields = ('id', 'name', 'email') class PersonDetail(PersonMixin, RetrieveAPIView): diff --git a/patchwork/api/project.py b/patchwork/api/project.py index 8901ab48..ce3ed581 100644 --- a/patchwork/api/project.py +++ b/patchwork/api/project.py @@ -76,6 +76,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') class ProjectDetail(ProjectMixin, RetrieveUpdateAPIView): diff --git a/patchwork/api/series.py b/patchwork/api/series.py index 7e40a321..f66f0d2b 100644 --- a/patchwork/api/series.py +++ b/patchwork/api/series.py @@ -59,6 +59,7 @@ class SeriesList(SeriesMixin, ListAPIView): filter_class = SeriesFilter search_fields = ('name',) + ordering_fields = ('id', 'name', 'date', 'submitter', 'received_all') class SeriesDetail(SeriesMixin, RetrieveAPIView): diff --git a/patchwork/api/user.py b/patchwork/api/user.py index 2c9f71b4..32fe836a 100644 --- a/patchwork/api/user.py +++ b/patchwork/api/user.py @@ -57,6 +57,7 @@ class UserList(UserMixin, ListAPIView): """List users.""" search_fields = ('username', 'first_name', 'last_name', 'email') + ordering_fields = ('id', 'username', 'email') class UserDetail(UserMixin, RetrieveUpdateAPIView): diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py index 82fd9c2a..67373502 100644 --- a/patchwork/settings/base.py +++ b/patchwork/settings/base.py @@ -147,8 +147,10 @@ REST_FRAMEWORK = { 'DEFAULT_FILTER_BACKENDS': ( 'django_filters.rest_framework.DjangoFilterBackend', 'rest_framework.filters.SearchFilter', + 'rest_framework.filters.OrderingFilter', ), 'SEARCH_PARAM': 'q', + 'ORDERING_PARAM': 'order', } #