|
16 | 16 | from django.urls import reverse
|
17 | 17 | from django.utils.deprecation import MiddlewareMixin
|
18 | 18 |
|
| 19 | +from readthedocs.builds.models import Version |
19 | 20 | from readthedocs.core.unresolver import (
|
20 | 21 | InvalidCustomDomainError,
|
21 | 22 | InvalidExternalDomainError,
|
|
25 | 26 | unresolver,
|
26 | 27 | )
|
27 | 28 | from readthedocs.core.utils import get_cache_tag
|
28 |
| -from readthedocs.projects.models import Feature, Project |
| 29 | +from readthedocs.projects.models import Feature |
29 | 30 | from readthedocs.proxito.cache import add_cache_tags, cache_response, private_response
|
30 | 31 | from readthedocs.proxito.redirects import redirect_to_https
|
31 | 32 |
|
@@ -293,20 +294,12 @@ def add_hosting_integrations_headers(self, request, response):
|
293 | 294 | project_slug = getattr(request, "path_project_slug", "")
|
294 | 295 | version_slug = getattr(request, "path_version_slug", "")
|
295 | 296 |
|
296 |
| - if project_slug: |
297 |
| - project = Project.objects.get(slug=project_slug) |
298 |
| - |
299 |
| - # Check for the feature flag |
300 |
| - if project.has_feature(Feature.HOSTING_INTEGRATIONS): |
301 |
| - addons = True |
302 |
| - else: |
303 |
| - # Check if the version forces injecting the addons (e.g. using `build.commands`) |
304 |
| - version = ( |
305 |
| - project.versions.filter(slug=version_slug).only("addons").first() |
306 |
| - ) |
307 |
| - if version and version.addons: |
308 |
| - addons = True |
309 |
| - |
| 297 | + if project_slug and version_slug: |
| 298 | + addons = Version.objects.filter( |
| 299 | + project__slug=project_slug, |
| 300 | + slug=version_slug, |
| 301 | + addons=True, |
| 302 | + ).exists() |
310 | 303 | if addons:
|
311 | 304 | response["X-RTD-Hosting-Integrations"] = "true"
|
312 | 305 |
|
|
0 commit comments