Skip to content

Commit

Permalink
API v3: remove last_build expandable field (#11730)
Browse files Browse the repository at this point in the history
* API v3: remove last_build expandable field

* Remove internal notes
  • Loading branch information
stsewd authored Oct 31, 2024
1 parent 88c7c04 commit 072212b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 68 deletions.
9 changes: 2 additions & 7 deletions docs/user/api/v3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ Project details
}

:query string expand: Add additional fields in the response.
Allowed values are ``active_versions``, ``active_versions.last_build`` and
``active_versions.last_build.config``. Multiple fields can be passed separated by commas.
Allowed values are: ``active_versions``.
Multiple fields can be passed separated by commas.

.. note::

Expand Down Expand Up @@ -588,7 +588,6 @@ Version detail
"aliases": ["VERSION"],
"hidden": false,
"type": "tag",
"last_build": "{BUILD}",
"privacy_level": "public",
"downloads": {
"pdf": "https://pip.readthedocs.io/_/downloads/pdf/pip/stable/",
Expand All @@ -613,10 +612,6 @@ Version detail
``null`` when it's not the stable version.
:>json boolean built: the version has at least one successful build.

:query string expand: Add additional fields in the response.
Allowed values are ``last_build`` and ``last_build.config``.
Multiple fields can be passed separated by commas.

Version update
++++++++++++++

Expand Down
2 changes: 0 additions & 2 deletions readthedocs/api/v3/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,6 @@ class Meta:
"privacy_level",
]

expandable_fields = {"last_build": (BuildSerializer,)}

def __init__(self, *args, resolver=None, version_serializer=None, **kwargs):
super().__init__(*args, **kwargs)

Expand Down
29 changes: 0 additions & 29 deletions readthedocs/api/v3/tests/responses/projects-detail.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,6 @@
},
"id": 2,
"identifier": "a1b2c3",
"last_build": {
"commit": "a1b2c3",
"config": {
"property": "test value"
},
"created": "2019-04-29T10:00:00Z",
"duration": 60,
"error": "",
"finished": "2019-04-29T10:01:00Z",
"id": 1,
"_links": {
"_self": "https://readthedocs.org/api/v3/projects/project/builds/1/",
"notifications": "https://readthedocs.org/api/v3/projects/project/builds/1/notifications/",
"project": "https://readthedocs.org/api/v3/projects/project/",
"version": "https://readthedocs.org/api/v3/projects/project/versions/v1.0/"
},
"urls": {
"build": "https://readthedocs.org/projects/project/builds/1/",
"project": "https://readthedocs.org/projects/project/",
"version": "https://readthedocs.org/dashboard/project/version/v1.0/edit/"
},
"project": "project",
"state": {
"code": "finished",
"name": "Finished"
},
"success": true,
"version": "v1.0"
},
"_links": {
"_self": "https://readthedocs.org/api/v3/projects/project/versions/v1.0/",
"builds": "https://readthedocs.org/api/v3/projects/project/versions/v1.0/builds/",
Expand Down
28 changes: 4 additions & 24 deletions readthedocs/api/v3/tests/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ def test_projects_detail_anonymous_user(self):
},
)
data = {
"expand": (
"active_versions,"
"active_versions.last_build,"
"active_versions.last_build.config,"
"permissions"
),
"expand": ("active_versions," "permissions"),
}
expected_response = self._get_response_dict("projects-detail")
expected_response["permissions"]["admin"] = False
Expand All @@ -138,12 +133,7 @@ def test_projects_detail(self):
},
)
data = {
"expand": (
"active_versions,"
"active_versions.last_build,"
"active_versions.last_build.config,"
"permissions"
),
"expand": ("active_versions," "permissions"),
}
expected_response = self._get_response_dict("projects-detail")

Expand All @@ -170,12 +160,7 @@ def test_projects_detail_other_user(self):
},
)
data = {
"expand": (
"active_versions,"
"active_versions.last_build,"
"active_versions.last_build.config,"
"permissions"
),
"expand": ("active_versions," "permissions"),
}
expected_response = self._get_response_dict("projects-detail")
expected_response["permissions"]["admin"] = False
Expand Down Expand Up @@ -203,12 +188,7 @@ def test_own_projects_detail_privacy_levels_enabled(self):
},
)
query_params = {
"expand": (
"active_versions,"
"active_versions.last_build,"
"active_versions.last_build.config,"
"permissions"
),
"expand": ("active_versions," "permissions"),
}

self.client.credentials(HTTP_AUTHORIZATION=f"Token {self.token.key}")
Expand Down
6 changes: 0 additions & 6 deletions readthedocs/api/v3/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ class ProjectsViewSetBase(
filterset_class = ProjectFilter
permit_list_expands = [
"active_versions",
"active_versions.last_build",
"active_versions.last_build.config",
"organization",
"permissions",
"teams",
Expand Down Expand Up @@ -356,10 +354,6 @@ class VersionsViewSet(

filterset_class = VersionFilter
permission_classes = [ReadOnlyPermission | (IsAuthenticated & IsProjectAdmin)]
permit_list_expands = [
"last_build",
"last_build.config",
]

def get_serializer_class(self):
"""
Expand Down

0 comments on commit 072212b

Please sign in to comment.