Sitecof : captcha pour les listes mail
This commit is contained in:
parent
9110e5b185
commit
72237fef60
6 changed files with 96 additions and 55 deletions
|
@ -1,5 +1,29 @@
|
|||
from django.shortcuts import render
|
||||
from django import forms
|
||||
from django.shortcuts import render, redirect
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
import re
|
||||
|
||||
def raw_calendar_view(request, year, month):
|
||||
return render(request, "cofcms/calendar_raw.html", {"month": month, "year": year})
|
||||
|
||||
class CaptchaForm(forms.Form):
|
||||
answer = forms.CharField(label="Réponse", max_length=32)
|
||||
|
||||
def clean_answer(self):
|
||||
value = self.cleaned_data["answer"]
|
||||
if not re.match(r"(les|the)? *ernests?", value.strip().lower()):
|
||||
raise forms.ValidationError(_("Réponse incorrecte"))
|
||||
|
||||
return value
|
||||
|
||||
def sympa_captcha_form_view(request):
|
||||
if request.method == "POST":
|
||||
form = CaptchaForm(request.POST)
|
||||
if form.is_valid():
|
||||
return render(request, "cofcms/sympa.html",
|
||||
{"redirect": "https://lists.ens.fr/wws/lists/"})
|
||||
else:
|
||||
form = CaptchaForm()
|
||||
|
||||
return render(request, "cofcms/sympa.html", {"form": form})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue