2023-07-14 18:29:07 +00:00
|
|
|
from re import Pattern
|
2023-06-22 08:27:56 +00:00
|
|
|
from django import forms
|
|
|
|
from django.core.exceptions import ValidationError
|
|
|
|
from django.utils.translation import gettext_lazy as txt
|
|
|
|
|
|
|
|
class SignbookForm(forms.Form):
|
|
|
|
name = forms.CharField(label="Name")
|
|
|
|
website = forms.CharField(label="Website", required=False)
|
|
|
|
email = forms.EmailField(label="Email", required=False)
|
|
|
|
comment = forms.CharField(label="Comment", required=False)
|
|
|
|
capcha = forms.CharField(label="Tell me that you love 'me'")
|
|
|
|
|
|
|
|
def validate_capcha(self):
|
|
|
|
if self.cleaned_data["capcha"].lower() != "i love me":
|
2023-07-14 18:29:07 +00:00
|
|
|
raise ValidationError(txt('Invalid captcha'), code="invalid")
|
2023-06-22 08:27:56 +00:00
|
|
|
return self
|