diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f0c1a04..cd375af8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/gestioncof/cms/locale/en/LC_MESSAGES/django.mo b/gestioncof/cms/locale/en/LC_MESSAGES/django.mo index ad390d63..40b2f45f 100644 Binary files a/gestioncof/cms/locale/en/LC_MESSAGES/django.mo and b/gestioncof/cms/locale/en/LC_MESSAGES/django.mo differ diff --git a/gestioncof/cms/locale/en/LC_MESSAGES/django.po b/gestioncof/cms/locale/en/LC_MESSAGES/django.po index 5c854f43..d586f73e 100644 --- a/gestioncof/cms/locale/en/LC_MESSAGES/django.po +++ b/gestioncof/cms/locale/en/LC_MESSAGES/django.po @@ -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 "LMMJVSD" -msgstr "" -"MTuWThFSaSu" +msgstr "MTuWThFSaSu" #: 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" +#~ " " diff --git a/gestioncof/cms/models.py b/gestioncof/cms/models.py index 1c88cccf..c0d07aad 100644 --- a/gestioncof/cms/models.py +++ b/gestioncof/cms/models.py @@ -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): diff --git a/gestioncof/cms/templates/cofcms/sympa.html b/gestioncof/cms/templates/cofcms/sympa.html index 119c0614..16a76f1b 100644 --- a/gestioncof/cms/templates/cofcms/sympa.html +++ b/gestioncof/cms/templates/cofcms/sympa.html @@ -1,26 +1,32 @@ -{% extends "cofcms/base.html" %} -{% load i18n %} +{% load i18n static %} -{% block content %} -
-

{% trans "Listes mail" %}

-
- -
-
- {% 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 %} -
-
-
- {% csrf_token %} - {% if erreur %}

{% trans erreur %}

{% endif %} -

{% blocktrans %}Comment s'appellent les poissons du bassin ?{% endblocktrans %}

- - -
-
-{% endblock %} +{% if redirect %} +

{% trans "Redirection vers" %} {{ redirect }}

+ +{% else %} + + + + + + +
+ + {% csrf_token %} +

{% blocktrans %}Comment s'appellent les poissons du bassin ?{% endblocktrans %}

+ {% for field in form %} + {% for error in field.errors %} +

{% trans error %}

+ {% endfor %} +

+ {{ field }} +

+ {% endfor %} + + +
+ + +{% endif %} diff --git a/gestioncof/cms/views.py b/gestioncof/cms/views.py index 1b9ce4e9..41bf0135 100644 --- a/gestioncof/cms/views.py +++ b/gestioncof/cms/views.py @@ -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})