[PATCH 2/2] REST: Expose 'Series.project'

Stephen Finucane stephen at that.guru
Sat Jan 7 09:52:59 AEDT 2017


Signed-off-by: Stephen Finucane <stephen at that.guru>
Cc: Andy Doan <andy.doan at linaro.org>
Cc: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
---
 patchwork/api/series.py          | 6 ++++--
 patchwork/tests/test_rest_api.py | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/patchwork/api/series.py b/patchwork/api/series.py
index ade37fb..44cf87f 100644
--- a/patchwork/api/series.py
+++ b/patchwork/api/series.py
@@ -29,12 +29,14 @@ class SeriesSerializer(HyperlinkedModelSerializer):
 
     class Meta:
         model = Series
-        fields = ('id', 'url', 'name', 'date', 'submitter', 'version', 'total',
-                  'received_total', 'received_all', 'cover_letter', 'patches')
+        fields = ('id', 'url', 'project', 'name', 'date', 'submitter',
+                  'version', 'total', 'received_total', 'received_all',
+                  'cover_letter', 'patches')
         read_only_fields = ('date', 'submitter', 'total', 'received_total',
                             'received_all', 'cover_letter', 'patches')
         extra_kwargs = {
             'url': {'view_name': 'api-series-detail'},
+            'project': {'view_name': 'api-project-detail'},
             'submitter': {'view_name': 'api-person-detail'},
             'cover_letter': {'view_name': 'api-cover-detail'},
             'patches': {'view_name': 'api-patch-detail'},
diff --git a/patchwork/tests/test_rest_api.py b/patchwork/tests/test_rest_api.py
index 0d1c702..cc1fcef 100644
--- a/patchwork/tests/test_rest_api.py
+++ b/patchwork/tests/test_rest_api.py
@@ -490,6 +490,8 @@ class TestSeriesAPI(APITestCase):
     def assertSerialized(self, series_obj, series_json):
         self.assertEqual(series_obj.id, series_json['id'])
         self.assertEqual(series_obj.name, series_json['name'])
+        self.assertIn(TestProjectAPI.api_url(series_obj.project.id),
+                      series_json['project'])
         self.assertIn(TestPersonAPI.api_url(series_obj.submitter.id),
                       series_json['submitter'])
         self.assertEqual(series_obj.patches.count(),
-- 
2.9.3



More information about the Patchwork mailing list