@ -225,25 +225,18 @@ class VideoPlaylistListAPIView(generics.ListAPIView):
queryset = queryset . filter ( collections__slug = collection_slug )
is_bookmark = ( self . request . query_params . get ( ' is_bookmark ' ) or self . request . query_params . get ( ' is_bookmarked ' ) or ' ' ) . lower ( )
if is_bookmark in ( ' true ' , ' 1 ' ) and self . request . user . is_authenticated :
if is_bookmark in ( ' true ' , ' 1 ' ) :
if not self . request . user . is_authenticated :
return queryset . none ( )
from apps.bookmark.models import Bookmark
from django.db.models import Q
bookmarked_playlist_ids = Bookmark . objects . filter (
user = self . request . user ,
service = Bookmark . ServiceChoices . VIDEO_PLAYLIST ,
service__in = [ Bookmark . ServiceChoices . VIDEO_PLAYLIST , Bookmark . ServiceChoices . VIDEO ] ,
status = True
) . values_list ( ' content_id ' , flat = True )
bookmarked_video_ids = Bookmark . objects . filter (
user = self . request . user ,
service = Bookmark . ServiceChoices . VIDEO ,
status = True
) . values_list ( ' content_id ' , flat = True )
queryset = queryset . filter (
Q ( id__in = bookmarked_playlist_ids ) | Q ( playlist_items__video__id__in = bookmarked_video_ids )
) . distinct ( )
queryset = queryset . filter ( id__in = bookmarked_playlist_ids )
sort = self . request . query_params . get ( ' sort ' , ' -created_at ' )
allowed_sorts = [
' created_at ' , ' -created_at ' , ' view_count ' , ' -view_count ' ,
@ -343,25 +336,18 @@ class VideoListAPIView(generics.ListAPIView):
queryset = queryset . filter ( collections__slug = collection_slug )
is_bookmark = ( self . request . query_params . get ( ' is_bookmark ' ) or self . request . query_params . get ( ' is_bookmarked ' ) or ' ' ) . lower ( )
if is_bookmark in ( ' true ' , ' 1 ' ) and self . request . user . is_authenticated :
if is_bookmark in ( ' true ' , ' 1 ' ) :
if not self . request . user . is_authenticated :
return queryset . none ( )
from apps.bookmark.models import Bookmark
from django.db.models import Q
bookmarked_playlist_ids = Bookmark . objects . filter (
user = self . request . user ,
service = Bookmark . ServiceChoices . VIDEO_PLAYLIST ,
service__in = [ Bookmark . ServiceChoices . VIDEO_PLAYLIST , Bookmark . ServiceChoices . VIDEO ] ,
status = True
) . values_list ( ' content_id ' , flat = True )
bookmarked_video_ids = Bookmark . objects . filter (
user = self . request . user ,
service = Bookmark . ServiceChoices . VIDEO ,
status = True
) . values_list ( ' content_id ' , flat = True )
queryset = queryset . filter (
Q ( id__in = bookmarked_playlist_ids ) | Q ( playlist_items__video__id__in = bookmarked_video_ids )
) . distinct ( )
queryset = queryset . filter ( id__in = bookmarked_playlist_ids )
sort = self . request . query_params . get ( ' sort ' , ' -created_at ' )
allowed_sorts = [
' created_at ' , ' -created_at ' , ' view_count ' , ' -view_count ' ,