Repository: readthedocs/readthedocs.org

Issue:
APIv3: `_links.notifications` is not returned for `Project`
We should update this serializer https://github.com/readthedocs/readthedocs.org/blob/7a58acb50b964bc60f19ea10a1e5135737d77d84/readthedocs/api/v3/serializers.py#L498-L508 to return `notifications`.


Discussion:

Resolving patch:
diff --git a/readthedocs/api/v3/serializers.py b/readthedocs/api/v3/serializers.py
--- a/readthedocs/api/v3/serializers.py
+++ b/readthedocs/api/v3/serializers.py
@@ -462,6 +462,7 @@ class ProjectLinksSerializer(BaseLinksSerializer):
     subprojects = serializers.SerializerMethodField()
     superproject = serializers.SerializerMethodField()
     translations = serializers.SerializerMethodField()
+    notifications = serializers.SerializerMethodField()
 
     def get__self(self, obj):
         path = reverse("projects-detail", kwargs={"project_slug": obj.slug})
@@ -530,6 +531,15 @@ def get_translations(self, obj):
         )
         return self._absolute_url(path)
 
+    def get_notifications(self, obj):
+        path = reverse(
+            "projects-notifications-list",
+            kwargs={
+                "parent_lookup_project__slug": obj.slug,
+            },
+        )
+        return self._absolute_url(path)
+
 
 class ProjectCreateSerializerBase(TaggitSerializer, FlexFieldsModelSerializer):
 


Test patch:
diff --git a/readthedocs/api/v3/tests/responses/projects-detail.json b/readthedocs/api/v3/tests/responses/projects-detail.json
--- a/readthedocs/api/v3/tests/responses/projects-detail.json
+++ b/readthedocs/api/v3/tests/responses/projects-detail.json
@@ -71,6 +71,7 @@
         "_self": "https://readthedocs.org/api/v3/projects/project/",
         "builds": "https://readthedocs.org/api/v3/projects/project/builds/",
         "environmentvariables": "https://readthedocs.org/api/v3/projects/project/environmentvariables/",
+        "notifications": "https://readthedocs.org/api/v3/projects/project/notifications/",
         "redirects": "https://readthedocs.org/api/v3/projects/project/redirects/",
         "subprojects": "https://readthedocs.org/api/v3/projects/project/subprojects/",
         "superproject": "https://readthedocs.org/api/v3/projects/project/superproject/",
diff --git a/readthedocs/api/v3/tests/responses/projects-list.json b/readthedocs/api/v3/tests/responses/projects-list.json
--- a/readthedocs/api/v3/tests/responses/projects-list.json
+++ b/readthedocs/api/v3/tests/responses/projects-list.json
@@ -47,6 +47,7 @@
                 "versions": "https://readthedocs.org/api/v3/projects/project/versions/",
                 "builds": "https://readthedocs.org/api/v3/projects/project/builds/",
                 "environmentvariables": "https://readthedocs.org/api/v3/projects/project/environmentvariables/",
+                "notifications": "https://readthedocs.org/api/v3/projects/project/notifications/",
                 "redirects": "https://readthedocs.org/api/v3/projects/project/redirects/",
                 "subprojects": "https://readthedocs.org/api/v3/projects/project/subprojects/",
                 "superproject": "https://readthedocs.org/api/v3/projects/project/superproject/",
diff --git a/readthedocs/api/v3/tests/responses/projects-list_POST.json b/readthedocs/api/v3/tests/responses/projects-list_POST.json
--- a/readthedocs/api/v3/tests/responses/projects-list_POST.json
+++ b/readthedocs/api/v3/tests/responses/projects-list_POST.json
@@ -3,6 +3,7 @@
         "_self": "https://readthedocs.org/api/v3/projects/test-project/",
         "builds": "https://readthedocs.org/api/v3/projects/test-project/builds/",
         "environmentvariables": "https://readthedocs.org/api/v3/projects/test-project/environmentvariables/",
+        "notifications": "https://readthedocs.org/api/v3/projects/test-project/notifications/",
         "redirects": "https://readthedocs.org/api/v3/projects/test-project/redirects/",
         "subprojects": "https://readthedocs.org/api/v3/projects/test-project/subprojects/",
         "superproject": "https://readthedocs.org/api/v3/projects/test-project/superproject/",
diff --git a/readthedocs/api/v3/tests/responses/projects-subprojects-detail.json b/readthedocs/api/v3/tests/responses/projects-subprojects-detail.json
--- a/readthedocs/api/v3/tests/responses/projects-subprojects-detail.json
+++ b/readthedocs/api/v3/tests/responses/projects-subprojects-detail.json
@@ -9,6 +9,7 @@
             "_self": "https://readthedocs.org/api/v3/projects/subproject/",
             "builds": "https://readthedocs.org/api/v3/projects/subproject/builds/",
             "environmentvariables": "https://readthedocs.org/api/v3/projects/subproject/environmentvariables/",
+            "notifications": "https://readthedocs.org/api/v3/projects/subproject/notifications/",
             "redirects": "https://readthedocs.org/api/v3/projects/subproject/redirects/",
             "subprojects": "https://readthedocs.org/api/v3/projects/subproject/subprojects/",
             "superproject": "https://readthedocs.org/api/v3/projects/subproject/superproject/",
diff --git a/readthedocs/api/v3/tests/responses/projects-subprojects-list.json b/readthedocs/api/v3/tests/responses/projects-subprojects-list.json
--- a/readthedocs/api/v3/tests/responses/projects-subprojects-list.json
+++ b/readthedocs/api/v3/tests/responses/projects-subprojects-list.json
@@ -14,6 +14,7 @@
                     "_self": "https://readthedocs.org/api/v3/projects/subproject/",
                     "builds": "https://readthedocs.org/api/v3/projects/subproject/builds/",
                     "environmentvariables": "https://readthedocs.org/api/v3/projects/subproject/environmentvariables/",
+                    "notifications": "https://readthedocs.org/api/v3/projects/subproject/notifications/",
                     "redirects": "https://readthedocs.org/api/v3/projects/subproject/redirects/",
                     "subprojects": "https://readthedocs.org/api/v3/projects/subproject/subprojects/",
                     "superproject": "https://readthedocs.org/api/v3/projects/subproject/superproject/",
diff --git a/readthedocs/api/v3/tests/responses/projects-subprojects-list_POST.json b/readthedocs/api/v3/tests/responses/projects-subprojects-list_POST.json
--- a/readthedocs/api/v3/tests/responses/projects-subprojects-list_POST.json
+++ b/readthedocs/api/v3/tests/responses/projects-subprojects-list_POST.json
@@ -9,6 +9,7 @@
             "_self": "https://readthedocs.org/api/v3/projects/new-project/",
             "builds": "https://readthedocs.org/api/v3/projects/new-project/builds/",
             "environmentvariables": "https://readthedocs.org/api/v3/projects/new-project/environmentvariables/",
+            "notifications": "https://readthedocs.org/api/v3/projects/new-project/notifications/",
             "redirects": "https://readthedocs.org/api/v3/projects/new-project/redirects/",
             "subprojects": "https://readthedocs.org/api/v3/projects/new-project/subprojects/",
             "superproject": "https://readthedocs.org/api/v3/projects/new-project/superproject/",
diff --git a/readthedocs/api/v3/tests/responses/projects-superproject.json b/readthedocs/api/v3/tests/responses/projects-superproject.json
--- a/readthedocs/api/v3/tests/responses/projects-superproject.json
+++ b/readthedocs/api/v3/tests/responses/projects-superproject.json
@@ -11,6 +11,7 @@
         "_self": "https://readthedocs.org/api/v3/projects/project/",
         "builds": "https://readthedocs.org/api/v3/projects/project/builds/",
         "environmentvariables": "https://readthedocs.org/api/v3/projects/project/environmentvariables/",
+        "notifications": "https://readthedocs.org/api/v3/projects/project/notifications/",
         "redirects": "https://readthedocs.org/api/v3/projects/project/redirects/",
         "subprojects": "https://readthedocs.org/api/v3/projects/project/subprojects/",
         "superproject": "https://readthedocs.org/api/v3/projects/project/superproject/",
diff --git a/readthedocs/api/v3/tests/responses/projects-versions-builds-list_POST.json b/readthedocs/api/v3/tests/responses/projects-versions-builds-list_POST.json
--- a/readthedocs/api/v3/tests/responses/projects-versions-builds-list_POST.json
+++ b/readthedocs/api/v3/tests/responses/projects-versions-builds-list_POST.json
@@ -39,6 +39,7 @@
             "builds": "https://readthedocs.org/api/v3/projects/project/builds/",
             "environmentvariables": "https://readthedocs.org/api/v3/projects/project/environmentvariables/",
             "redirects": "https://readthedocs.org/api/v3/projects/project/redirects/",
+            "notifications": "https://readthedocs.org/api/v3/projects/project/notifications/",
             "subprojects": "https://readthedocs.org/api/v3/projects/project/subprojects/",
             "superproject": "https://readthedocs.org/api/v3/projects/project/superproject/",
             "translations": "https://readthedocs.org/api/v3/projects/project/translations/",
diff --git a/readthedocs/api/v3/tests/responses/remoterepositories-list.json b/readthedocs/api/v3/tests/responses/remoterepositories-list.json
--- a/readthedocs/api/v3/tests/responses/remoterepositories-list.json
+++ b/readthedocs/api/v3/tests/responses/remoterepositories-list.json
@@ -21,6 +21,7 @@
           "_self": "https://readthedocs.org/api/v3/projects/project/",
           "builds": "https://readthedocs.org/api/v3/projects/project/builds/",
           "environmentvariables": "https://readthedocs.org/api/v3/projects/project/environmentvariables/",
+          "notifications": "https://readthedocs.org/api/v3/projects/project/notifications/",
           "redirects": "https://readthedocs.org/api/v3/projects/project/redirects/",
           "subprojects": "https://readthedocs.org/api/v3/projects/project/subprojects/",
           "superproject": "https://readthedocs.org/api/v3/projects/project/superproject/",