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
adhérents ni des cotisations.
### Site du COF
Captcha fonctionnel pour les mailing-listes
## Upcoming
## Version 0.6 - 27/0702020

View file

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-29 16:04+0200\n"
"PO-Revision-Date: 2020-03-29 16:08+0200\n"
"POT-Creation-Date: 2020-08-22 12:28+0200\n"
"PO-Revision-Date: 2020-08-22 12:29+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: en\n"
@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\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
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
msgid "<th>L</th><th>M</th><th>M</th><th>J</th><th>V</th><th>S</th><th>D</th>"
msgstr ""
"<th>M</th><th>Tu</th><th>W</th><th>Th</th><th>F</th><th>Sa</th><th>Su</th>"
msgstr "<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
msgid "Le "
@ -65,33 +64,15 @@ msgstr "Show mail address"
msgid "Agenda"
msgstr "Agenda"
#: templates/cofcms/sympa.html:6
msgid "Listes mail"
msgstr "Mailing lists"
#: templates/cofcms/sympa.html:4
msgid "Redirection vers"
msgstr "Redirecting to"
#: templates/cofcms/sympa.html:11
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
#: templates/cofcms/sympa.html:18
msgid "Comment s'appellent les poissons du bassin ?"
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
msgid "le {datestart}"
msgstr "on {datestart}"
@ -111,7 +92,27 @@ msgstr "from {datestart} to {dateend}{common}"
msgid "du {datestart}{common} à {timestart} au {dateend} à {timeend}"
msgstr "from {datestart}{common} {timestart} to {dateend} {timeend}"
#: templatetags/cofcms_tags.py:164
#: templatetags/cofcms_tags.py:165
#, python-brace-format
msgid "le {datestart} à {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))
# 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
class IFrameBlock(blocks.StructBlock):

View file

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