Remplace recaptcha par hcaptcha
This commit is contained in:
parent
2350109a33
commit
47dd078b6a
3 changed files with 18 additions and 4 deletions
|
@ -50,7 +50,7 @@ INSTALLED_APPS = (
|
||||||
+ [
|
+ [
|
||||||
"bda",
|
"bda",
|
||||||
"petitscours",
|
"petitscours",
|
||||||
"captcha",
|
"hcaptcha",
|
||||||
"kfet",
|
"kfet",
|
||||||
"kfet.open",
|
"kfet.open",
|
||||||
"channels",
|
"channels",
|
||||||
|
|
|
@ -1,14 +1,28 @@
|
||||||
from captcha.fields import ReCaptchaField
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
from django.forms.models import inlineformset_factory
|
from django.forms.models import inlineformset_factory
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from hcaptcha.fields import hCaptchaField
|
||||||
|
|
||||||
from petitscours.models import PetitCoursAbility, PetitCoursDemande
|
from petitscours.models import PetitCoursAbility, PetitCoursDemande
|
||||||
|
|
||||||
|
|
||||||
|
class hCaptchaFieldWithErrors(hCaptchaField):
|
||||||
|
"""
|
||||||
|
Pour l'instant, hCaptchaField ne supporte pas le paramètre `error_messages` lors de
|
||||||
|
l'initialisation. Du coup, on les redéfinit à la main.
|
||||||
|
"""
|
||||||
|
|
||||||
|
default_error_messages = {
|
||||||
|
"required": _("Veuillez vérifier que vous êtes bien humain·e."),
|
||||||
|
"error_hcaptcha": _("Erreur lors de la vérification."),
|
||||||
|
"invalid_hcaptcha": _("Échec de la vérification !"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class DemandeForm(ModelForm):
|
class DemandeForm(ModelForm):
|
||||||
captcha = ReCaptchaField(attrs={"theme": "clean", "lang": "fr"})
|
captcha = hCaptchaFieldWithErrors()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
|
@ -3,7 +3,7 @@ Django==2.2.*
|
||||||
django-autocomplete-light==3.3.*
|
django-autocomplete-light==3.3.*
|
||||||
django-cas-ng==3.6.*
|
django-cas-ng==3.6.*
|
||||||
django-djconfig==0.8.0
|
django-djconfig==0.8.0
|
||||||
django-recaptcha==1.4.0
|
django-hCaptcha==0.1.0
|
||||||
icalendar
|
icalendar
|
||||||
Pillow
|
Pillow
|
||||||
django-bootstrap-form==3.3
|
django-bootstrap-form==3.3
|
||||||
|
|
Loading…
Reference in a new issue