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.
33 lines
937 B
33 lines
937 B
2 years ago
|
from django.views.generic import FormView
|
||
|
|
||
|
from seminar.models import Osoba
|
||
|
from seminar.views import formularOKView
|
||
|
from .forms import UcastnikVyrociForm
|
||
|
from .models import UcastnikVyroci
|
||
|
|
||
|
|
||
|
# Create your views here.
|
||
|
|
||
|
class VyrociView(FormView):
|
||
|
""" Zobrazí organizátorský rozcestník."""
|
||
|
template_name = 'vyroci/vyroci.html'
|
||
|
form_class = UcastnikVyrociForm
|
||
|
|
||
|
def get_context_data(self, **kwargs):
|
||
|
context = super().get_context_data(**kwargs)
|
||
|
context['ucastnici'] = UcastnikVyroci.objects.all()
|
||
|
return context
|
||
|
|
||
|
def form_valid(self, form):
|
||
|
form.save()
|
||
|
|
||
|
return formularOKView(self.request, "Úspěšně jsi se přihlásil na víkendovku")
|
||
|
def get_initial(self):
|
||
|
initial = super().get_initial()
|
||
|
if self.request.user.is_authenticated:
|
||
|
osoba = Osoba.objects.filter(user=self.request.user).first()
|
||
|
if osoba is not None:
|
||
|
initial["jmeno"] = osoba.plne_jmeno()
|
||
|
initial["email"] = osoba.email
|
||
|
return initial
|