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.
16 lines
443 B
16 lines
443 B
1 year ago
|
from django.core.exceptions import ValidationError
|
||
|
from django.forms import ModelForm
|
||
|
from .models import OdpovedUcastnika, SpravnaOdpoved
|
||
|
|
||
|
|
||
|
class SifrovackaForm(ModelForm):
|
||
|
class Meta:
|
||
|
model = OdpovedUcastnika
|
||
|
fields = ["sifra", "odpoved", ]
|
||
|
|
||
|
def clean_sifra(self):
|
||
|
sifra = self.cleaned_data.get('sifra')
|
||
|
if SpravnaOdpoved.objects.filter(sifra=sifra).count() == 0:
|
||
|
raise ValidationError("Špatné číslo šifry")
|
||
|
return sifra
|