diff mbox series

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

Message ID 20240313065642.385843-4-andrepapoti@gmail.com
State New
Headers show
Series [1/9] models: Add Note model | expand

Commit Message

andrepapoti March 13, 2024, 6:56 a.m. UTC
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@gmail.com>
---
 patchwork/api/patch.py | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

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',