[PATCH 4/9] api: Add Note to Patch Serializer

andrepapoti andrepapoti at gmail.com
Wed Mar 13 17:56:36 AEDT 2024


Patch serializer returns a fields containing it's notes.
Some notes may be filtered out depending on the request's user and on
the note maintainer_only attribute

Signed-off-by: andrepapoti <andrepapoti at gmail.com>
---
 patchwork/api/patch.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py
index 443c382..8fd3456 100644
--- a/patchwork/api/patch.py
+++ b/patchwork/api/patch.py
@@ -85,6 +85,7 @@ class PatchListSerializer(BaseHyperlinkedModelSerializer):
     mbox = SerializerMethodField()
     series = SeriesSerializer(read_only=True)
     comments = SerializerMethodField()
+    notes = SerializerMethodField()
     check = SerializerMethodField()
     checks = SerializerMethodField()
     tags = SerializerMethodField()
@@ -108,6 +109,11 @@ class PatchListSerializer(BaseHyperlinkedModelSerializer):
             reverse('api-patch-comment-list', kwargs={'patch_id': patch.id})
         )
 
+    def get_notes(self, patch):
+        return self.context.get('request').build_absolute_uri(
+            reverse('api-patch-note-list', kwargs={'patch_id': patch.id})
+        )
+
     def get_check(self, instance):
         return instance.combined_check_state
 
@@ -173,6 +179,7 @@ class PatchListSerializer(BaseHyperlinkedModelSerializer):
             'mbox',
             'series',
             'comments',
+            'notes',
             'check',
             'checks',
             'tags',
@@ -191,6 +198,7 @@ class PatchListSerializer(BaseHyperlinkedModelSerializer):
             'mbox',
             'series',
             'comments',
+            'notes',
             'check',
             'checks',
             'tags',
-- 
2.44.0



More information about the Patchwork mailing list