You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.5 KiB

from django.shortcuts import render
from prednasky.forms import NewPrednaskyForm
from prednasky.models import Seznam, Hlasovani, Prednaska
from django.shortcuts import HttpResponseRedirect
from models import Prednaska, Seznam, STAV_NAVRH
from seminar.models import Soustredeni
def newPrednaska(request):
# hlasovani se vztahuje k nejnovejsimu soustredeni
sous = Soustredeni.objects.first()
seznam = Seznam.objects.filter(soustredeni = sous, stav = STAV_NAVRH).first()
print seznam
# obsluha formulare
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()
9 years ago
print("q:"+i[1:])
hlasovani.prednaska = Prednaska.objects.filter(pk = int(i[1:]))[0]
hlasovani.body = int(request.POST[i])
hlasovani.ucastnik = jmeno
hlasovani.seznam = seznam
hlasovani.save()
# presmerovani na prave vzniklou galerii
return HttpResponseRedirect('./hotovo')
else:
form = NewPrednaskyForm()
return render(request, 'prednasky/Base.html',
{ 'form' : form,
'prednasky' : seznam,
})
def Prednaska_hotovo(request):
return render(request, 'prednasky/hotovo.html')
# Create your views here.