Sitecof : captcha pour les listes mail

This commit is contained in:
Evarin 2020-08-22 12:34:08 +02:00
parent 9110e5b185
commit 72237fef60
6 changed files with 96 additions and 55 deletions

View file

@ -25,6 +25,10 @@ Uniquement un modèle BDSProfile pour le moment…
Uniquement un modèle simple de clubs avec des respos. Aucune gestion des Uniquement un modèle simple de clubs avec des respos. Aucune gestion des
adhérents ni des cotisations. adhérents ni des cotisations.
### Site du COF
Captcha fonctionnel pour les mailing-listes
## Upcoming ## Upcoming
## Version 0.6 - 27/0702020 ## Version 0.6 - 27/0702020

View file

@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-29 16:04+0200\n" "POT-Creation-Date: 2020-08-22 12:28+0200\n"
"PO-Revision-Date: 2020-03-29 16:08+0200\n" "PO-Revision-Date: 2020-08-22 12:29+0200\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"Language: en\n" "Language: en\n"
@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.7.1\n" "X-Generator: Poedit 2.0.6\n"
#: templates/cofcms/base.html:7 #: templates/cofcms/base.html:7
msgid "Association des élèves de l'ENS Ulm" msgid "Association des élèves de l'ENS Ulm"
@ -24,8 +24,7 @@ msgstr "Student Association of the École Normale Supérieure"
#: templates/cofcms/calendar.html:9 #: templates/cofcms/calendar.html:9
msgid "<th>L</th><th>M</th><th>M</th><th>J</th><th>V</th><th>S</th><th>D</th>" msgid "<th>L</th><th>M</th><th>M</th><th>J</th><th>V</th><th>S</th><th>D</th>"
msgstr "" msgstr "<th>M</th><th>Tu</th><th>W</th><th>Th</th><th>F</th><th>Sa</th><th>Su</th>"
"<th>M</th><th>Tu</th><th>W</th><th>Th</th><th>F</th><th>Sa</th><th>Su</th>"
#: templates/cofcms/calendar.html:17 #: templates/cofcms/calendar.html:17
msgid "Le " msgid "Le "
@ -65,33 +64,15 @@ msgstr "Show mail address"
msgid "Agenda" msgid "Agenda"
msgstr "Agenda" msgstr "Agenda"
#: templates/cofcms/sympa.html:6 #: templates/cofcms/sympa.html:4
msgid "Listes mail" msgid "Redirection vers"
msgstr "Mailing lists" msgstr "Redirecting to"
#: templates/cofcms/sympa.html:11 #: templates/cofcms/sympa.html:18
msgid ""
"\n"
" Tous les abonnements aux listes de diffusion de mail à l'ENS "
"se gèrent sur le serveur de mail SYMPA\n"
"\n"
" Pour y accéder : Merci de répondre à cette question anti-"
"robots.\n"
" "
msgstr ""
"\n"
" All the mailing list subscriptions can be managed through "
"the SYMPA mail server\n"
"\n"
" In order to access it, please answer this antispam "
"question.\n"
" "
#: templates/cofcms/sympa.html:21
msgid "Comment s'appellent les poissons du bassin ?" msgid "Comment s'appellent les poissons du bassin ?"
msgstr "How are called the fish in the school's pond?" msgstr "How are called the fish in the school's pond?"
#: templatetags/cofcms_tags.py:134 templatetags/cofcms_tags.py:162 #: templatetags/cofcms_tags.py:134 templatetags/cofcms_tags.py:163
#, python-brace-format #, python-brace-format
msgid "le {datestart}" msgid "le {datestart}"
msgstr "on {datestart}" msgstr "on {datestart}"
@ -111,7 +92,27 @@ msgstr "from {datestart} to {dateend}{common}"
msgid "du {datestart}{common} à {timestart} au {dateend} à {timeend}" msgid "du {datestart}{common} à {timestart} au {dateend} à {timeend}"
msgstr "from {datestart}{common} {timestart} to {dateend} {timeend}" msgstr "from {datestart}{common} {timestart} to {dateend} {timeend}"
#: templatetags/cofcms_tags.py:164 #: templatetags/cofcms_tags.py:165
#, python-brace-format #, python-brace-format
msgid "le {datestart} à {timestart}" msgid "le {datestart} à {timestart}"
msgstr "on {datestart} at {timestart}" msgstr "on {datestart} at {timestart}"
#: views.py:16
msgid "Réponse incorrecte"
msgstr "Invalid answer"
#~ msgid "Listes mail"
#~ msgstr "Mailing lists"
#~ msgid ""
#~ "\n"
#~ " Tous les abonnements aux listes de diffusion de mail à l'ENS se gèrent sur le serveur de mail SYMPA\n"
#~ "\n"
#~ " Pour y accéder : Merci de répondre à cette question anti-robots.\n"
#~ " "
#~ msgstr ""
#~ "\n"
#~ " All the mailing list subscriptions can be managed through the SYMPA mail server\n"
#~ "\n"
#~ " In order to access it, please answer this antispam question.\n"
#~ " "

View file

@ -42,6 +42,12 @@ class COFRootPage(RoutablePageMixin, Page, COFActuIndexMixin):
return raw_calendar_view(request, int(year), int(month)) return raw_calendar_view(request, int(year), int(month))
# Captcha Mailing-listes
@route(r"^sympa/captcha/$")
def sympa_captcha(self, request):
from .views import sympa_captcha_form_view
return sympa_captcha_form_view(request)
# Block iframe # Block iframe
class IFrameBlock(blocks.StructBlock): class IFrameBlock(blocks.StructBlock):

View file

@ -1,26 +1,32 @@
{% extends "cofcms/base.html" %} {% load i18n static %}
{% load i18n %}
{% block content %} {% if redirect %}
<section class="intro"> <p>{% trans "Redirection vers" %} <a href="{{ redirect }}" target="_parent">{{ redirect }}</a></p>
<h1>{% trans "Listes mail" %}</h1> <script type="text/javascript">
</section> top.location = "{{ redirect }}";
</script>
<section class="pagecontent"> {% else %}
<article class="paragraph"> <!doctype html>
{% blocktrans %} <html>
Tous les abonnements aux listes de diffusion de mail à l'ENS se gèrent sur le serveur de mail SYMPA <head>
<link rel="stylesheet" type="text/css" href="{% static "fonts/SourceSansPro/sourceSansPro.css" %}"/>
Pour y accéder : Merci de répondre à cette question anti-robots. <link rel="stylesheet" type="text/css" href="{% static "cofcms/css/screen.css" %}"/>
{% endblocktrans %} <body>
</article>
<article class="paragraph"> <article class="paragraph">
<form method="POST" action=""> <form method="POST" action="">
{% csrf_token %} {% csrf_token %}
{% if erreur %}<p class="erreur">{% trans erreur %}</p>{% endif %}
<p>{% blocktrans %}Comment s'appellent les poissons du bassin ?{% endblocktrans %}</p> <p>{% blocktrans %}Comment s'appellent les poissons du bassin ?{% endblocktrans %}</p>
<input type="text" name="bassin" /> {% for field in form %}
{% for error in field.errors %}
<p class="erreur">{% trans error %}</p>
{% endfor %}
<p align="center">
{{ field }}
</p>
{% endfor %}
<input type="submit" /> <input type="submit" />
</form>
</article> </article>
</section> </body>
{% endblock %} </html>
{% endif %}

View file

@ -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): def raw_calendar_view(request, year, month):
return render(request, "cofcms/calendar_raw.html", {"month": month, "year": year}) 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})