from django.shortcuts import render from prednasky.forms import NewPrednaskyForm from prednasky.models import Seznam, Hlasovani, Prednaska from django.shortcuts import HttpResponseRedirect def newPrednaska(request): # zjistime k jakemu soustredeni se vaze nove vytvarena galerie prednasky = Seznam.objects.first() # obsluha formulare umoznujiciho multiple nahravani fotek if request.method == 'POST': form = NewPrednaskyForm(request.POST, request.FILES) if form.is_valid(): jmeno = form.cleaned_data['ucastnik'] for i in request.POST: if i[0] == 'q': hlasovani = Hlasovani() hlasovani.prednaska = Prednaska.objects.filter(pk = i[1])[0] hlasovani.body = int(request.POST[i]) hlasovani.ucastnik = jmeno hlasovani.save() # presmerovani na prave vzniklou galerii return HttpResponseRedirect('./hotovo') else: form = NewPrednaskyForm() return render(request, 'prednasky/Base.html', { 'form' : form, 'prednasky' : prednasky, }) def Prednaska(request): return render(request, 'prednasky/hotovo.html') # Create your views here.