|
|
@ -3,7 +3,7 @@ from django.shortcuts import get_object_or_404, redirect, render
|
|
|
|
from django.urls import reverse
|
|
|
|
from django.urls import reverse
|
|
|
|
from re import match
|
|
|
|
from re import match
|
|
|
|
|
|
|
|
|
|
|
|
from .forms import CreatePlaylistForm, StartSessionForm
|
|
|
|
from .forms import CreatePlaylistForm
|
|
|
|
from .spreadsheet import get_sheet_data
|
|
|
|
from .spreadsheet import get_sheet_data
|
|
|
|
from ..core.models import Artist, Playlist, Session
|
|
|
|
from ..core.models import Artist, Playlist, Session
|
|
|
|
|
|
|
|
|
|
|
@ -92,18 +92,13 @@ def session(request):
|
|
|
|
return redirect('create_playlist')
|
|
|
|
return redirect('create_playlist')
|
|
|
|
|
|
|
|
|
|
|
|
def playlist(request, playlist):
|
|
|
|
def playlist(request, playlist):
|
|
|
|
form = StartSessionForm()
|
|
|
|
|
|
|
|
playlist = get_object_or_404(Playlist, pk=playlist)
|
|
|
|
playlist = get_object_or_404(Playlist, pk=playlist)
|
|
|
|
return render(request, 'host/playlist.html', {'form': form, 'num_artists': playlist.artist_set.count()})
|
|
|
|
return render(request, 'host/playlist.html', {'num_artists': playlist.artist_set.count()})
|
|
|
|
|
|
|
|
|
|
|
|
def start_session(request, playlist):
|
|
|
|
def start_session(request, playlist):
|
|
|
|
playlist = get_object_or_404(Playlist, pk=playlist)
|
|
|
|
playlist = get_object_or_404(Playlist, pk=playlist)
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
form = StartSessionForm(request.POST)
|
|
|
|
|
|
|
|
if not form.is_valid():
|
|
|
|
|
|
|
|
return redirect('playlist', playlist=playlist.pk)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 'session' in request.session:
|
|
|
|
if 'session' in request.session:
|
|
|
|
return redirect('session')
|
|
|
|
return redirect('session')
|
|
|
|
|
|
|
|
|
|
|
|