aboutsummaryrefslogtreecommitdiffstats
path: root/alphabetlearning/payments/forms.py
blob: bfa23acdf5aff771e3e8951e2453c5f83c92662a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from django import forms
from django_recaptcha.fields import ReCaptchaField
from django_recaptcha.widgets import ReCaptchaV3

from .models import EmailVerification


class EmailVerificationForm(forms.ModelForm):
    captcha = ReCaptchaField(widget=ReCaptchaV3())

    class Meta:
        model = EmailVerification
        fields = ["email"]

    def clean_email(self):
        email = self.cleaned_data.get("email")
        if EmailVerification.objects.filter(email=email).exists():
            raise forms.ValidationError("This email address is already in use.")
        return email