Remove unnecessary forms (CSRF protection works without them)

main
Luca 2 years ago
parent db6037b32e
commit f299811620

@ -2,6 +2,3 @@ from django import forms
class CreatePlaylistForm(forms.Form):
spreadsheet_url = forms.URLField(label='Link zur Tabelle')
class StartSessionForm(forms.Form):
pass

@ -3,7 +3,7 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from re import match
from .forms import CreatePlaylistForm, StartSessionForm
from .forms import CreatePlaylistForm
from .spreadsheet import get_sheet_data
from ..core.models import Artist, Playlist, Session
@ -92,18 +92,13 @@ def session(request):
return redirect('create_playlist')
def playlist(request, playlist):
form = StartSessionForm()
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):
playlist = get_object_or_404(Playlist, pk=playlist)
if request.method == 'POST':
form = StartSessionForm(request.POST)
if not form.is_valid():
return redirect('playlist', playlist=playlist.pk)
if 'session' in request.session:
return redirect('session')

@ -1,4 +1,2 @@
from django import forms
class JoinSessionForm(forms.Form):
pass

@ -1,6 +1,5 @@
from django.shortcuts import get_object_or_404, redirect, render
from .forms import JoinSessionForm
from ..core.models import Session
# Create your views here.
@ -8,16 +7,11 @@ from ..core.models import Session
def join_session(request, session):
session = get_object_or_404(Session, pk=session)
form = JoinSessionForm()
if request.method == 'POST':
form = JoinSessionForm(request.POST)
if not form.is_valid():
return render(request, 'vote/join_session.html', {'form': JoinSessionForm()})
request.session['session'] = session.token
return redirect('current_artist', session.playlist.pk)
return render(request, 'vote/join_session.html', {'form': form})
return render(request, 'vote/join_session.html', {})
def artist(request, playlist, offset=None):
session = get_object_or_404(Session, pk=request.session.get('session'))

Loading…
Cancel
Save