Skip to content

Commit 21b4e67

Browse files
authored
Addons: manage single version projects (#10686)
* Addons: access downloads only when `version != None` Solves https://read-the-docs.sentry.io/issues/4437207301/?project=148442 * Addons: empty versions and downlaods when single version project
1 parent 8d36a6e commit 21b4e67

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

readthedocs/proxito/views/hosting.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,21 @@ def _v0(self, project, version, build, filename):
174174
It tries to follow some similarity with the APIv3 for already-known resources
175175
(Project, Version, Build, etc).
176176
"""
177-
versions_active_built_not_hidden = (
178-
Version.internal.public(project=project, only_active=True, only_built=True)
179-
.exclude(hidden=True)
180-
.only("slug")
181-
.order_by("slug")
182-
)
177+
version_downloads = []
178+
versions_active_built_not_hidden = Version.objects.none()
179+
180+
if not project.single_version:
181+
versions_active_built_not_hidden = (
182+
Version.internal.public(
183+
project=project, only_active=True, only_built=True
184+
)
185+
.exclude(hidden=True)
186+
.only("slug")
187+
.order_by("slug")
188+
)
189+
if version:
190+
version_downloads = version.get_downloads(pretty=True).items()
191+
183192
project_translations = (
184193
project.translations.all().only("language").order_by("language")
185194
)
@@ -283,7 +292,7 @@ def _v0(self, project, version, build, filename):
283292
"name": name,
284293
"url": url,
285294
}
286-
for name, url in version.get_downloads(pretty=True).items()
295+
for name, url in version_downloads
287296
],
288297
# TODO: find a way to get this data in a reliably way.
289298
# We don't have a simple way to map a URL to a file in the repository.

0 commit comments

Comments
 (0)