|  | 
| 23 | 23 | from django.views.generic import ListView | 
| 24 | 24 | from taggit.models import Tag | 
| 25 | 25 | 
 | 
|  | 26 | +from readthedocs.api.mixins import CDNCacheTagsMixin | 
| 26 | 27 | from readthedocs.builds.constants import BUILD_STATE_FINISHED | 
| 27 | 28 | from readthedocs.builds.constants import EXTERNAL | 
| 28 | 29 | from readthedocs.builds.constants import INTERNAL | 
| @@ -299,7 +300,7 @@ def verify_project_token(cls, token, project_slug): | 
| 299 | 300 | project_badge = never_cache(ProjectBadgeView.as_view()) | 
| 300 | 301 | 
 | 
| 301 | 302 | 
 | 
| 302 |  | -class ProjectDownloadMediaBase(CDNCacheControlMixin, ServeDocsMixin, View): | 
|  | 303 | +class ProjectDownloadMediaBase(CDNCacheControlMixin, CDNCacheTagsMixin, ServeDocsMixin, View): | 
| 303 | 304 |     # Use new-style URLs (same domain as docs) or old-style URLs (dashboard URL) | 
| 304 | 305 |     same_domain_url = False | 
| 305 | 306 | 
 | 
| @@ -382,13 +383,28 @@ def get( | 
| 382 | 383 |                 slug=version_slug, | 
| 383 | 384 |             ) | 
| 384 | 385 | 
 | 
|  | 386 | +        # TODO don't do this, it's a leftover of trying to use CDNCacheTagsMixin | 
|  | 387 | +        # without class level variables. See proxito.views.serve for | 
|  | 388 | +        # other instances of this pattern to update. | 
|  | 389 | +        # See: https://github.com/readthedocs/readthedocs.org/pull/12495 | 
|  | 390 | +        self.project = version.project | 
|  | 391 | +        self.version = version | 
|  | 392 | + | 
| 385 | 393 |         return self._serve_dowload( | 
| 386 | 394 |             request=request, | 
| 387 | 395 |             project=version.project, | 
| 388 | 396 |             version=version, | 
| 389 | 397 |             type_=type_, | 
| 390 | 398 |         ) | 
| 391 | 399 | 
 | 
|  | 400 | +    def _get_project(self): | 
|  | 401 | +        """Hack for CDNCacheTagsMixin, get project set in `get()`.""" | 
|  | 402 | +        return self.project | 
|  | 403 | + | 
|  | 404 | +    def _get_version(self): | 
|  | 405 | +        """Hack for CDNCacheTagsMixin, get version set in `get()`.""" | 
|  | 406 | +        return self.version | 
|  | 407 | + | 
| 392 | 408 | 
 | 
| 393 | 409 | class ProjectDownloadMedia(SettingsOverrideObject): | 
| 394 | 410 |     _default_class = ProjectDownloadMediaBase | 
|  | 
0 commit comments