@ -50,7 +50,7 @@ class VideoCategoryListAPIView(generics.ListAPIView):
return VideoCategory . objects . filter ( status = True ) . prefetch_related (
return VideoCategory . objects . filter ( status = True ) . prefetch_related (
Prefetch (
Prefetch (
' playlists ' ,
' playlists ' ,
queryset = VideoPlaylist . objects . filter ( status = True , playlist_items__isnull = Fals e ) . distinct ( )
queryset = VideoPlaylist . objects . filter ( status = True , playlist_items__video__status = Tru e ) . distinct ( )
)
)
) . order_by ( ' order ' )
) . order_by ( ' order ' )
@ -89,7 +89,7 @@ class PinnedVideoCollectionListView(generics.ListAPIView):
status = True ,
status = True ,
display_position = VideoCollection . DisplayPosition . PINNED ,
display_position = VideoCollection . DisplayPosition . PINNED ,
related_playlists__status = True ,
related_playlists__status = True ,
related_playlists__playlist_items__isnull = Fals e
related_playlists__playlist_items__video__status = Tru e
) . distinct ( ) . order_by ( ' order ' , ' -created_at ' )
) . distinct ( ) . order_by ( ' order ' , ' -created_at ' )
# Filter by bookmarks if requested
# Filter by bookmarks if requested
@ -161,7 +161,7 @@ class MiddleVideoCollectionListView(generics.ListAPIView):
status = True ,
status = True ,
display_position = VideoCollection . DisplayPosition . MIDDLE ,
display_position = VideoCollection . DisplayPosition . MIDDLE ,
related_playlists__status = True ,
related_playlists__status = True ,
related_playlists__playlist_items__isnull = Fals e
related_playlists__playlist_items__video__status = Tru e
) . distinct ( ) . order_by ( ' order ' , ' -created_at ' )
) . distinct ( ) . order_by ( ' order ' , ' -created_at ' )
@ -243,7 +243,7 @@ class VideoPlaylistListAPIView(generics.ListAPIView):
def get_queryset ( self ) :
def get_queryset ( self ) :
queryset = VideoPlaylist . objects . filter (
queryset = VideoPlaylist . objects . filter (
status = True ,
status = True ,
playlist_items__isnull = Fals e
playlist_items__video__status = Tru e
) . distinct ( ) . order_by ( ' order ' , ' -created_at ' )
) . distinct ( ) . order_by ( ' order ' , ' -created_at ' )
# Search by title if search parameter is provided
# Search by title if search parameter is provided
@ -355,7 +355,7 @@ class VideoListAPIView(generics.ListAPIView):
def get_queryset ( self ) :
def get_queryset ( self ) :
queryset = VideoPlaylist . objects . filter (
queryset = VideoPlaylist . objects . filter (
status = True ,
status = True ,
playlist_items__isnull = Fals e
playlist_items__video__status = Tru e
) . distinct ( ) . order_by ( ' order ' , ' -created_at ' )
) . distinct ( ) . order_by ( ' order ' , ' -created_at ' )
# Search by title if search parameter is provided
# Search by title if search parameter is provided
@ -425,7 +425,7 @@ class VideoPlaylistDetailAPIView(generics.RetrieveAPIView):
return super ( ) . get ( request , * args , * * kwargs )
return super ( ) . get ( request , * args , * * kwargs )
def get_queryset ( self ) :
def get_queryset ( self ) :
return VideoPlaylist . objects . filter ( status = True , playlist_items__isnull = Fals e ) . distinct ( )
return VideoPlaylist . objects . filter ( status = True , playlist_items__video__status = Tru e ) . distinct ( )
def retrieve ( self , request , * args , * * kwargs ) :
def retrieve ( self , request , * args , * * kwargs ) :
instance = self . get_object ( )
instance = self . get_object ( )
@ -457,7 +457,7 @@ class VideoDetailAPIView(Gone410ViewMixin, CanonicalSlugViewSetMixin, generics.R
return super ( ) . get ( request , * args , * * kwargs )
return super ( ) . get ( request , * args , * * kwargs )
def get_queryset ( self ) :
def get_queryset ( self ) :
return VideoPlaylist . objects . al l( )
return VideoPlaylist . objects . filter ( status = True , p laylist_items__video__status = True ) . distinct ( )
def retrieve ( self , request , * args , * * kwargs ) :
def retrieve ( self , request , * args , * * kwargs ) :
instance = self . get_object ( )
instance = self . get_object ( )