[PATCH 2/4] REST: expose patch state in series list and detail views

Philippe Pepiot phil at philpep.org
Mon Jul 17 05:32:10 AEST 2017


This allow to display state for each patch or the series in list and
detail API view.

Signed-off-by: Philippe Pepiot <phil at philpep.org>
---
 patchwork/api/embedded.py | 3 ++-
 patchwork/api/series.py   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/patchwork/api/embedded.py b/patchwork/api/embedded.py
index ada8ad5..0854166 100644
--- a/patchwork/api/embedded.py
+++ b/patchwork/api/embedded.py
@@ -88,10 +88,11 @@ class CoverLetterSerializer(HyperlinkedModelSerializer):
 
 
 class PatchSerializer(MboxMixin, HyperlinkedModelSerializer):
+    state = StateField()
 
     class Meta:
         model = models.Patch
-        fields = ('id', 'url', 'msgid', 'date', 'name', 'mbox')
+        fields = ('id', 'url', 'msgid', 'date', 'name', 'mbox', 'state')
         read_only_fields = fields
         extra_kwargs = {
             'url': {'view_name': 'api-patch-detail'},
diff --git a/patchwork/api/series.py b/patchwork/api/series.py
index 12f9277..d1b9a99 100644
--- a/patchwork/api/series.py
+++ b/patchwork/api/series.py
@@ -61,7 +61,8 @@ class SeriesMixin(object):
     serializer_class = SeriesSerializer
 
     def get_queryset(self):
-        return Series.objects.all().prefetch_related('patches',)\
+        return Series.objects.all()\
+            .prefetch_related('patches', 'patches__state')\
             .select_related('submitter', 'cover_letter', 'project')
 
 
-- 
2.11.0



More information about the Patchwork mailing list