Skip to content

Commit

Permalink
APIv3: add _links.notifications to Project resource (#11155)
Browse files Browse the repository at this point in the history
* APIv3: add `_links.notifications` to `Project` resource

Closes #11055

* Update tests

* Update more JSON responses with the link

* Update more JSON files
  • Loading branch information
humitos committed Feb 26, 2024
1 parent 23bf20c commit 112d9cd
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions readthedocs/api/v3/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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):

Expand Down
1 change: 1 addition & 0 deletions readthedocs/api/v3/tests/responses/projects-detail.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
1 change: 1 addition & 0 deletions readthedocs/api/v3/tests/responses/projects-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
1 change: 1 addition & 0 deletions readthedocs/api/v3/tests/responses/projects-list_POST.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down

0 comments on commit 112d9cd

Please sign in to comment.