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.
18 lines
572 B
18 lines
572 B
from django.core.exceptions import ValidationError
|
|
from django.forms import ModelForm, Textarea
|
|
from .models import OdpovedUcastnika, SpravnaOdpoved
|
|
|
|
|
|
class SifrovackaForm(ModelForm):
|
|
class Meta:
|
|
model = OdpovedUcastnika
|
|
fields = ["sifra", "odpoved", ]
|
|
widgets = {
|
|
"odpoved": Textarea(attrs={'rows': 1, 'cols': 30}),
|
|
}
|
|
|
|
def clean_sifra(self):
|
|
sifra = self.cleaned_data.get('sifra')
|
|
if SpravnaOdpoved.objects.filter(sifra=sifra).count() == 0:
|
|
raise ValidationError("Tohle číslo šifry v databázi nemáme. Zkontrolujte si ho prosím.")
|
|
return sifra
|
|
|