@@ -770,53 +770,30 @@ def has_versions(self):
770
770
def has_aliases (self ):
771
771
return self .aliases .exists ()
772
772
773
- def has_pdf (self , version_slug = LATEST ):
773
+ def has_media (self , type_ , version_slug = LATEST ):
774
774
path = self .get_production_media_path (
775
- type_ = 'pdf' , version_slug = version_slug
775
+ type_ = type_ , version_slug = version_slug
776
776
)
777
777
if os .path .exists (path ):
778
778
return True
779
779
780
780
if settings .RTD_BUILD_MEDIA_STORAGE :
781
781
storage = get_storage_class (settings .RTD_BUILD_MEDIA_STORAGE )()
782
782
storage_path = self .get_storage_path (
783
- type_ = 'pdf' , version_slug = version_slug
783
+ type_ = type_ , version_slug = version_slug
784
784
)
785
785
return storage .exists (storage_path )
786
786
787
787
return False
788
788
789
- def has_epub (self , version_slug = LATEST ):
790
- path = self .get_production_media_path (
791
- type_ = 'epub' , version_slug = version_slug
792
- )
793
- if os .path .exists (path ):
794
- return True
795
-
796
- if settings .RTD_BUILD_MEDIA_STORAGE :
797
- storage = get_storage_class (settings .RTD_BUILD_MEDIA_STORAGE )()
798
- storage_path = self .get_storage_path (
799
- type_ = 'epub' , version_slug = version_slug
800
- )
801
- return storage .exists (storage_path )
789
+ def has_pdf (self , version_slug = LATEST ):
790
+ return self .has_media ('pdf' , version_slug = version_slug )
802
791
803
- return False
792
+ def has_epub (self , version_slug = LATEST ):
793
+ return self .has_media ('epub' , version_slug = version_slug )
804
794
805
795
def has_htmlzip (self , version_slug = LATEST ):
806
- path = self .get_production_media_path (
807
- type_ = 'htmlzip' , version_slug = version_slug
808
- )
809
- if os .path .exists (path ):
810
- return True
811
-
812
- if settings .RTD_BUILD_MEDIA_STORAGE :
813
- storage = get_storage_class (settings .RTD_BUILD_MEDIA_STORAGE )()
814
- storage_path = self .get_storage_path (
815
- type_ = 'htmlzip' , version_slug = version_slug
816
- )
817
- return storage .exists (storage_path )
818
-
819
- return False
796
+ return self .has_media ('htmlzip' , version_slug = version_slug )
820
797
821
798
@property
822
799
def sponsored (self ):
0 commit comments