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.

35 lines
975 B

from django.views.generic import FormView, ListView
from personalni.models import Osoba
from various.views.pomocne import formularOKView
from .forms import UcastnikVyrociForm
from .models import UcastnikVyroci
class VyrociView(FormView):
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ě ses přihlásil na sraz")
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
class VyrociListView(ListView):
template_name = 'vyroci/vyroci_list.html'
model = UcastnikVyroci