Bc. Petr Pecha
9 years ago
5 changed files with 98 additions and 0 deletions
@ -0,0 +1,8 @@ |
|||
# coding: utf-8 |
|||
from django import forms |
|||
|
|||
class NewPrednaskyForm(forms.Form): |
|||
ucastnik = forms.CharField(label = 'Tvoje jméno', max_length = 100) |
|||
|
|||
|
|||
|
@ -0,0 +1,40 @@ |
|||
{% extends 'base.html' %} |
|||
|
|||
{% load humanize %} |
|||
{% load staticfiles %} |
|||
|
|||
{% block title %} |
|||
Hlasování o přednáškách |
|||
{% endblock %} |
|||
|
|||
{% block content %} |
|||
|
|||
<p> |
|||
Jak moc by ses chtěl(a) zúčastnit následujících přednášek? |
|||
<br> |
|||
<span style="font-size: 75%">Obtížnost 1 je nejlehčí, 3 nejtěžší.</span> |
|||
</p> |
|||
|
|||
<form enctype="multipart/form-data" action="." method="post"> |
|||
{% csrf_token %} |
|||
<table>{{form.as_table}} |
|||
</table> |
|||
<table> |
|||
{% for p in prednasky.prednaska_set.all %} |
|||
<tr><td><label>{{p.org}}: <span style="font-size: 175%">{{p.nazev}}</span></label></td></tr> |
|||
<tr><td><p><i>{{p.anotace}}</i></p></td></tr> |
|||
<tr><td><label>Obor: </label> {{p.obor}}</td></tr> |
|||
<tr><td><label>Obtížnost: </label> {{p.obtiznost}}</td> </tr> |
|||
{% if p.klicova %}<tr><td><label>Klíčová slova: </label> {{p.klicova}}</td></tr>{% endif%} |
|||
<tr><td>Hodnocení: |
|||
<INPUT TYPE="radio" NAME="q{{p.pk}}" VALUE="-1"> rozhodně nechci |
|||
<INPUT TYPE="radio" NAME="q{{p.pk}}" VALUE="0" checked> je mi to jedno |
|||
<INPUT TYPE="radio" NAME="q{{p.pk}}" VALUE="1"> rozhodně chci |
|||
</td></tr> |
|||
<tr><td> </td></tr> |
|||
{% endfor %} |
|||
<tr><td><input name="odeslat" type="submit" value="Odeslat"></td><tr> |
|||
</table> |
|||
</form> |
|||
|
|||
{% endblock %} |
@ -0,0 +1,11 @@ |
|||
{% extends 'base.html' %} |
|||
|
|||
{% load humanize %} |
|||
{% load staticfiles %} |
|||
|
|||
|
|||
{% block content %} |
|||
|
|||
<h1> Děkujeme. </h1> |
|||
|
|||
{% endblock %} |
@ -1,3 +1,37 @@ |
|||
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. |
|||
|
Loading…
Reference in new issue