Now projects can also be accessed through urls by /projects/?name=<project_name>
---
api/rest.py | 6 ++++++
tests/test_rest.py | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/api/rest.py b/api/rest.py
index a9b6be3..21f4609 100644
--- a/api/rest.py
+++ b/api/rest.py
@@ -148,6 +148,12 @@ class ProjectsViewSet(viewsets.ModelViewSet):
permission_classes = (PatchewPermission,)
authentication_classes = (CsrfExemptSessionAuthentication, )
+ def get_queryset(self):
+ name = self.request.query_params.get('name', None)
+ if name is not None:
+ return Project.objects.filter(name=name).order_by('id')
+ return Project.objects.all().order_by('id')
+
@action(methods=['post'], detail=True, permission_classes=[ImportPermission])
def update_project_head(self, request, pk=None):
"""
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 980d61a..937a39a 100755
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -441,6 +441,12 @@ class RestTest(PatchewTestCase):
self.assertEqual(resp.data['results'][3]['resource_uri'], self.PROJECT_BASE + 'messages/e0858c00-ccb6-e533-ee3e-9ba84ca45a7b@redhat.com/')
self.assertEqual(resp.data['results'][3]['subject'], 'Re: [Qemu-devel] [PATCH v4 0/2] Report format specific info for LUKS block driver')
+ def test_project_filter(self):
+ resp = self.api_client.get(self.REST_BASE + 'projects/?name=QEMU')
+ project = resp.data['results'][0]
+ self.assertEquals(project['name'], "QEMU")
+ self.assertEquals(project['mailing_list'], "qemu-devel@nongnu.org")
+
def test_schema(self):
resp = self.api_client.get(self.REST_BASE + 'schema/')
self.assertEqual(resp.status_code, 200)
--
2.15.1 (Apple Git-101)
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel