|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
from django.conf import settings
|
|
|
|
|
from django.contrib.auth.decorators import login_required
|
|
|
|
|
from django.db import transaction
|
|
|
|
|
from django.db.models import F, Min
|
|
|
|
|
from django.shortcuts import get_object_or_404, redirect, render
|
|
|
|
@ -16,6 +17,7 @@ def get_absolute_join_session_url(request, session):
|
|
|
|
|
|
|
|
|
|
# Create your views here.
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
@transaction.atomic
|
|
|
|
|
def create_playlist(request):
|
|
|
|
|
form = CreatePlaylistForm()
|
|
|
|
@ -86,6 +88,7 @@ def create_playlist(request):
|
|
|
|
|
|
|
|
|
|
return render(request, 'host/create_playlist.html', {'error': None, 'form': form})
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
def break_view(request):
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
session = get_object_or_404(Session, pk=request.session.get('session'))
|
|
|
|
@ -100,6 +103,7 @@ def break_view(request):
|
|
|
|
|
|
|
|
|
|
return render(request, 'host/break.html', {'video_id': content.video_id})
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
def add_break_content(request):
|
|
|
|
|
form = AddBreakContentForm()
|
|
|
|
|
|
|
|
|
@ -121,6 +125,7 @@ def add_break_content(request):
|
|
|
|
|
|
|
|
|
|
return render(request, 'host/add_break_content.html', {'form': form})
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
def session(request):
|
|
|
|
|
if 'session' in request.session:
|
|
|
|
|
try:
|
|
|
|
@ -131,10 +136,12 @@ def session(request):
|
|
|
|
|
|
|
|
|
|
return redirect('create_playlist')
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
def playlist(request, playlist):
|
|
|
|
|
playlist = get_object_or_404(Playlist, pk=playlist)
|
|
|
|
|
return render(request, 'host/playlist.html', {'num_artists': playlist.artist_set.count()})
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
def start_session(request, playlist):
|
|
|
|
|
playlist = get_object_or_404(Playlist, pk=playlist)
|
|
|
|
|
|
|
|
|
@ -150,6 +157,7 @@ def start_session(request, playlist):
|
|
|
|
|
|
|
|
|
|
return redirect('playlist', playlist=playlist.pk)
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
|
def view_artist(request, playlist, offset):
|
|
|
|
|
artists = get_object_or_404(Playlist, pk=playlist).artist_set
|
|
|
|
|
artist = artists.order_by('id')[offset]
|
|
|
|
|