]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
REST: Integrate searching
authorStephen Finucane <stephen@that.guru>
Mon, 14 Nov 2016 00:05:37 +0000 (00:05 +0000)
committerStephen Finucane <stephen@that.guru>
Sun, 22 Jan 2017 21:49:31 +0000 (21:49 +0000)
Search by way of the 'q' parameter on many endpoints.

Signed-off-by: Stephen Finucane <stephen@that.guru>
patchwork/api/cover.py
patchwork/api/patch.py
patchwork/api/person.py
patchwork/api/project.py
patchwork/api/series.py
patchwork/api/user.py
patchwork/settings/base.py

index 6374ce9e0ab68a50654b870f96201411d350ea44..0b6b546cb3191e12097a897e2a50dfcb823433b3 100644 (file)
@@ -68,6 +68,7 @@ class CoverLetterList(ListAPIView):
 
     serializer_class = CoverLetterListSerializer
     filter_class = CoverLetterFilter
+    search_fields = ('name',)
 
     def get_queryset(self):
         qs = CoverLetter.objects.all().prefetch_related('series')\
index d12464f9092b3a06b32e18e150edbfca2042fc2d..fc5a0ee1ac856b04b9ebe8d80775c66c7086b86f 100644 (file)
@@ -119,6 +119,7 @@ class PatchList(ListAPIView):
     permission_classes = (PatchworkPermission,)
     serializer_class = PatchListSerializer
     filter_class = PatchFilter
+    search_fields = ('name',)
 
     def get_queryset(self):
         return Patch.objects.all().with_tag_counts()\
index 2c1ca15d9982cb8aa4f139c1faa7abdc14c95e31..10cf781c0980ca0979f8fc5ab1c92aac68eed066 100644 (file)
@@ -46,7 +46,7 @@ class PersonMixin(object):
 class PersonList(PersonMixin, ListAPIView):
     """List users."""
 
-    pass
+    search_fields = ('name', 'email')
 
 
 class PersonDetail(PersonMixin, RetrieveAPIView):
index 3cc2c32580ade0ce2fe7e524f124b36e61930ec0..8901ab48b3ca390ccd86692a1b45c2595080e919 100644 (file)
@@ -74,7 +74,8 @@ class ProjectMixin(object):
 class ProjectList(ProjectMixin, ListAPIView):
     """List projects."""
 
-    pass
+    search_fields = ('link_name', 'list_id', 'list_email', 'web_url',
+                     'scm_url', 'webscm_url')
 
 
 class ProjectDetail(ProjectMixin, RetrieveUpdateAPIView):
index dc360d53bf20c8b44908ae9377d7fd8ccc4917d6..7e40a3215ded943e809bff753cd0986f1edb2d15 100644 (file)
@@ -58,6 +58,7 @@ class SeriesList(SeriesMixin, ListAPIView):
     """List series."""
 
     filter_class = SeriesFilter
+    search_fields = ('name',)
 
 
 class SeriesDetail(SeriesMixin, RetrieveAPIView):
index 2153cc9b8550834311bf1e45d051f48fa24f79c9..2c9f71b49aa67e75439a9b463129babb24157bcb 100644 (file)
@@ -56,7 +56,7 @@ class UserMixin(object):
 class UserList(UserMixin, ListAPIView):
     """List users."""
 
-    pass
+    search_fields = ('username', 'first_name', 'last_name', 'email')
 
 
 class UserDetail(UserMixin, RetrieveUpdateAPIView):
index 35b85c7d41dfecda9db13fe8997228b86134015a..82fd9c2ad3763d22fcb661c35796022ad1a7ac3e 100644 (file)
@@ -146,7 +146,9 @@ REST_FRAMEWORK = {
     'DEFAULT_PAGINATION_CLASS': 'patchwork.api.base.LinkHeaderPagination',
     'DEFAULT_FILTER_BACKENDS': (
         'django_filters.rest_framework.DjangoFilterBackend',
+        'rest_framework.filters.SearchFilter',
     ),
+    'SEARCH_PARAM': 'q',
 }
 
 #