Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API v3: remove last_build expandable field #11730

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 1 addition & 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 Expand Up @@ -753,6 +751,7 @@ class ProjectSerializer(FlexFieldsModelSerializer):
programming_language = ProgrammingLanguageSerializer()
repository = RepositorySerializer(source="*")
urls = ProjectURLsSerializer(source="*")
# These should check for permissions!
subproject_of = serializers.SerializerMethodField()
translation_of = serializers.SerializerMethodField()
default_branch = serializers.CharField(source="get_default_branch")
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
29 changes: 5 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 Expand Up @@ -304,6 +284,7 @@ def test_projects_superproject_other_user(self):
response = self.client.get(url)
self.assertEqual(response.status_code, 404)

# NOTE: this test is slow
def test_projects_sync_versions(self):
# Ensure a default version exists to sync
self.project.update_latest_version()
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
Loading