Web M&M
https://mam.matfyz.cz
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.
38 lines
1.3 KiB
38 lines
1.3 KiB
from django.shortcuts import render
|
|
from prednasky.forms import NewPrednaskyForm
|
|
from prednasky.models import Seznam_old, Hlasovani, Prednaska
|
|
from django.shortcuts import HttpResponseRedirect
|
|
|
|
def newPrednaska(request):
|
|
# zjistime k jakemu soustredeni se vaze nove vytvarena galerie
|
|
prednasky = Seznam_old.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()
|
|
print("q:"+i[1:])
|
|
hlasovani.prednaska = Prednaska.objects.filter(pk = int(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_hotovo(request):
|
|
return render(request, 'prednasky/hotovo.html')
|
|
|
|
|
|
# Create your views here.
|
|
|