[PATCH 39/51] api: Add a way to retrieve the list of pending reviews

Damien Lespiau damien.lespiau at intel.com
Sat Sep 12 01:55:12 AEST 2015


Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 patchwork/urls.py      |  4 ++++
 patchwork/views/api.py | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/patchwork/urls.py b/patchwork/urls.py
index 7052941..36fc5f9 100644
--- a/patchwork/urls.py
+++ b/patchwork/urls.py
@@ -30,6 +30,9 @@ import patchwork.views.api as api
 # /self
 users_router = routers.SimpleRouter()
 users_router.register('self', api.UserViewSet)
+# /self/reviews
+self_reviews_router = routers.SimpleRouter()
+self_reviews_router.register('self/reviews', api.SeriesReviewsViewSet)
 # /projects/$project/
 project_router = routers.SimpleRouter()
 project_router.register('projects', api.ProjectViewSet)
@@ -52,6 +55,7 @@ urlpatterns = patterns('',
 
     # API
     (r'^api/1.0/', include(users_router.urls)),
+    (r'^api/1.0/', include(self_reviews_router.urls)),
     (r'^api/1.0/', include(project_router.urls)),
     (r'^api/1.0/', include(series_list_router.urls)),
     (r'^api/1.0/', include(series_router.urls)),
diff --git a/patchwork/views/api.py b/patchwork/views/api.py
index 8ab17b3..4b843b9 100644
--- a/patchwork/views/api.py
+++ b/patchwork/views/api.py
@@ -62,6 +62,18 @@ class SeriesListMixin:
     ordering_fields = ('name', 'n_patches', 'submitter__name', 'reviewer__name',
                         'submitted', 'last_updated')
 
+class SeriesReviewsViewSet(mixins.ListModelMixin,
+                           SeriesListMixin,
+                           viewsets.GenericViewSet):
+    permission_classes = (UserPermission, )
+
+    def get_queryset(self):
+        filter_kwargs = { 'reviewer': self.request.user }
+
+        # Ensure queryset is re-evaluated on each request.
+        queryset = self.queryset.filter(**filter_kwargs)
+        return queryset
+
 class ProjectViewSet(viewsets.ViewSet):
     permission_classes = (MaintainerPermission, )
     model = Project
-- 
2.1.0



More information about the Patchwork mailing list