Browse Source

prednasky | form a jeho vyhodnocovani

remotes/origin/bug
Bc. Petr Pecha 9 years ago
parent
commit
5812ef343a
  1. 8
      prednasky/forms.py
  2. 40
      prednasky/templates/prednasky/Base.html
  3. 11
      prednasky/templates/prednasky/hotovo.html
  4. 34
      prednasky/views.py
  5. 5
      seminar/urls.py

8
prednasky/forms.py

@ -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)

40
prednasky/templates/prednasky/Base.html

@ -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>&nbsp;</td></tr>
{% endfor %}
<tr><td><input name="odeslat" type="submit" value="Odeslat"></td><tr>
</table>
</form>
{% endblock %}

11
prednasky/templates/prednasky/hotovo.html

@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% load humanize %}
{% load staticfiles %}
{% block content %}
<h1> Děkujeme. </h1>
{% endblock %}

34
prednasky/views.py

@ -1,3 +1,37 @@
from django.shortcuts import render 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. # Create your views here.

5
seminar/urls.py

@ -3,10 +3,15 @@ from django.conf.urls import patterns, url
from django.contrib.auth.decorators import user_passes_test from django.contrib.auth.decorators import user_passes_test
from . import views, export from . import views, export
from utils import staff_member_required from utils import staff_member_required
from prednasky.views import newPrednaska, Prednaska
staff_member_required = user_passes_test(lambda u: u.is_staff) staff_member_required = user_passes_test(lambda u: u.is_staff)
urlpatterns = [ urlpatterns = [
# prednasky
url(r'^prednasky/$', newPrednaska),
url(r'^prednasky/hotovo$', Prednaska),
url(r'^co-je-MaM/organizatori/$', views.CojemamOrganizatoriView.as_view(), name='organizatori'), url(r'^co-je-MaM/organizatori/$', views.CojemamOrganizatoriView.as_view(), name='organizatori'),
url(r'^co-je-MaM/organizatori/organizovali/$', views.CojemamOrganizatoriStariView.as_view(), name='stari_organizatori'), url(r'^co-je-MaM/organizatori/organizovali/$', views.CojemamOrganizatoriStariView.as_view(), name='stari_organizatori'),

Loading…
Cancel
Save