From ce346d6b053977aec728f9111de7289e84607752 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 20 Sep 2023 12:16:34 +0200 Subject: [PATCH 1/2] APIv3: return `single_version` field on `Project` resource For some reason we weren't returning this field in the API response. I understand there is no reason to not do it. I added `single_version` field in the response API so we can make some decisions from the addons based on its value. Required by https://github.com/readthedocs/addons/issues/140 --- docs/user/api/v3.rst | 1 + readthedocs/api/v3/serializers.py | 1 + readthedocs/api/v3/tests/responses/projects-detail.json | 3 ++- readthedocs/api/v3/tests/responses/projects-list.json | 3 ++- readthedocs/api/v3/tests/responses/projects-list_POST.json | 3 ++- .../api/v3/tests/responses/projects-subprojects-detail.json | 3 ++- .../api/v3/tests/responses/projects-subprojects-list.json | 3 ++- .../api/v3/tests/responses/projects-subprojects-list_POST.json | 3 ++- readthedocs/api/v3/tests/responses/projects-superproject.json | 3 ++- .../v3/tests/responses/projects-versions-builds-list_POST.json | 3 ++- 10 files changed, 18 insertions(+), 8 deletions(-) diff --git a/docs/user/api/v3.rst b/docs/user/api/v3.rst index e1a04c49aa2..595622f5b9c 100644 --- a/docs/user/api/v3.rst +++ b/docs/user/api/v3.rst @@ -279,6 +279,7 @@ Project details }, "privacy_level": "public", "external_builds_privacy_level": "public", + "single_version": false, "_links": { "_self": "/api/v3/projects/pip/", "versions": "/api/v3/projects/pip/versions/", diff --git a/readthedocs/api/v3/serializers.py b/readthedocs/api/v3/serializers.py index 522e2462502..0fb14f0155e 100644 --- a/readthedocs/api/v3/serializers.py +++ b/readthedocs/api/v3/serializers.py @@ -638,6 +638,7 @@ class Meta: "tags", "privacy_level", "external_builds_privacy_level", + "single_version", # NOTE: ``expandable_fields`` must not be included here. Otherwise, # they will be tried to be rendered and fail # 'active_versions', diff --git a/readthedocs/api/v3/tests/responses/projects-detail.json b/readthedocs/api/v3/tests/responses/projects-detail.json index a525b737f5b..bfeb346917a 100644 --- a/readthedocs/api/v3/tests/responses/projects-detail.json +++ b/readthedocs/api/v3/tests/responses/projects-detail.json @@ -107,5 +107,6 @@ } ], "privacy_level": "public", - "external_builds_privacy_level": "public" + "external_builds_privacy_level": "public", + "single_version": false } diff --git a/readthedocs/api/v3/tests/responses/projects-list.json b/readthedocs/api/v3/tests/responses/projects-list.json index d56efe714f9..216d37d235d 100644 --- a/readthedocs/api/v3/tests/responses/projects-list.json +++ b/readthedocs/api/v3/tests/responses/projects-list.json @@ -53,7 +53,8 @@ "translations": "https://readthedocs.org/api/v3/projects/project/translations/" }, "privacy_level": "public", - "external_builds_privacy_level": "public" + "external_builds_privacy_level": "public", + "single_version": false } ] } diff --git a/readthedocs/api/v3/tests/responses/projects-list_POST.json b/readthedocs/api/v3/tests/responses/projects-list_POST.json index cc16ee5b63a..7eb2ac36db4 100644 --- a/readthedocs/api/v3/tests/responses/projects-list_POST.json +++ b/readthedocs/api/v3/tests/responses/projects-list_POST.json @@ -44,5 +44,6 @@ } ], "privacy_level": "public", - "external_builds_privacy_level": "public" + "external_builds_privacy_level": "public", + "single_version": false } diff --git a/readthedocs/api/v3/tests/responses/projects-subprojects-detail.json b/readthedocs/api/v3/tests/responses/projects-subprojects-detail.json index 2ea48c06446..46e9a40b989 100644 --- a/readthedocs/api/v3/tests/responses/projects-subprojects-detail.json +++ b/readthedocs/api/v3/tests/responses/projects-subprojects-detail.json @@ -49,6 +49,7 @@ } ], "privacy_level": "public", - "external_builds_privacy_level": "public" + "external_builds_privacy_level": "public", + "single_version": false } } diff --git a/readthedocs/api/v3/tests/responses/projects-subprojects-list.json b/readthedocs/api/v3/tests/responses/projects-subprojects-list.json index ba20f98b185..ceaf2dca448 100644 --- a/readthedocs/api/v3/tests/responses/projects-subprojects-list.json +++ b/readthedocs/api/v3/tests/responses/projects-subprojects-list.json @@ -54,7 +54,8 @@ } ], "privacy_level": "public", - "external_builds_privacy_level": "public" + "external_builds_privacy_level": "public", + "single_version": false } } ] diff --git a/readthedocs/api/v3/tests/responses/projects-subprojects-list_POST.json b/readthedocs/api/v3/tests/responses/projects-subprojects-list_POST.json index 0ac731b3614..b8be0702756 100644 --- a/readthedocs/api/v3/tests/responses/projects-subprojects-list_POST.json +++ b/readthedocs/api/v3/tests/responses/projects-subprojects-list_POST.json @@ -49,6 +49,7 @@ } ], "privacy_level": "public", - "external_builds_privacy_level": "public" + "external_builds_privacy_level": "public", + "single_version": false } } diff --git a/readthedocs/api/v3/tests/responses/projects-superproject.json b/readthedocs/api/v3/tests/responses/projects-superproject.json index b618848a962..03fc35847e2 100644 --- a/readthedocs/api/v3/tests/responses/projects-superproject.json +++ b/readthedocs/api/v3/tests/responses/projects-superproject.json @@ -48,5 +48,6 @@ } ], "privacy_level": "public", - "external_builds_privacy_level": "public" + "external_builds_privacy_level": "public", + "single_version": false } 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 index 3f66594d6ca..2bbe17b8899 100644 --- a/readthedocs/api/v3/tests/responses/projects-versions-builds-list_POST.json +++ b/readthedocs/api/v3/tests/responses/projects-versions-builds-list_POST.json @@ -74,7 +74,8 @@ } ], "privacy_level": "public", - "external_builds_privacy_level": "public" + "external_builds_privacy_level": "public", + "single_version": false }, "triggered": true, "version": { From 710f3919aa4819381bbb803c02b9b348822937db Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 20 Sep 2023 16:46:03 +0200 Subject: [PATCH 2/2] Add field where it was missing --- .../api/v3/tests/responses/remoterepositories-list.json | 3 ++- readthedocs/proxito/tests/responses/v0.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/readthedocs/api/v3/tests/responses/remoterepositories-list.json b/readthedocs/api/v3/tests/responses/remoterepositories-list.json index cf3f9ba7b04..55762d7f782 100644 --- a/readthedocs/api/v3/tests/responses/remoterepositories-list.json +++ b/readthedocs/api/v3/tests/responses/remoterepositories-list.json @@ -49,7 +49,8 @@ }, "users": [{ "username": "testuser" }], "privacy_level": "public", - "external_builds_privacy_level": "public" + "external_builds_privacy_level": "public", + "single_version": false }], "remote_organization": { "avatar_url": "https://avatars.githubusercontent.com/u/366329?v=4", diff --git a/readthedocs/proxito/tests/responses/v0.json b/readthedocs/proxito/tests/responses/v0.json index 07f2f57c268..765c2a0703e 100644 --- a/readthedocs/proxito/tests/responses/v0.json +++ b/readthedocs/proxito/tests/responses/v0.json @@ -23,6 +23,7 @@ "type": "git", "url": "https://github.com/readthedocs/project" }, + "single_version": false, "slug": "project", "subproject_of": null, "tags": ["project", "tag", "test"],