Skip to content

Commit

Permalink
fix bug with playlist when added draft or password protected video
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitloup committed May 4, 2020
1 parent aaa8f02 commit a4245d9
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions pod/playlist/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,28 @@ def playlist_add(request, playlist):
if request.is_ajax():
if request.POST.get('video'):
video = get_object_or_404(Video, slug=request.POST['video'])
new = PlaylistElement()
new.playlist = playlist
new.video = video
new.position = playlist.last()
new.save()
some_data_to_dump = {
'success': '{0}'.format(
_('The video has been added to your playlist.'))
}
msg = None
if video.is_draft:
msg = _(
'A video in draft mode cannot be added to a playlist.')
if video.password:
msg = _(
'A video with a password cannot be added to a playlist.')

if msg:
some_data_to_dump = {
'fail': '{0}'.format(msg)
}
else:
new = PlaylistElement()
new.playlist = playlist
new.video = video
new.position = playlist.last()
new.save()
some_data_to_dump = {
'success': '{0}'.format(
_('The video has been added to your playlist.'))
}
else:
some_data_to_dump = {
'fail': '{0}'.format(
Expand Down

0 comments on commit a4245d9

Please sign in to comment.