Ajout d'un antispam

Fix #227
This commit is contained in:
Jean-Marie Favreau 2024-11-29 20:09:48 +01:00
parent d55d029fc7
commit 21b42e4fee
4 changed files with 11 additions and 2 deletions

View File

@ -56,8 +56,11 @@ INSTALLED_APPS = [
"robots",
"debug_toolbar",
"cache_cleaner",
"honeypot",
]
HONEYPOT_FIELD_NAME = "alias_name"
SITE_ID = 1
MIDDLEWARE = [

View File

@ -1,5 +1,6 @@
{% extends "agenda_culturel/page-admin.html" %}
{% load static %}
{% load honeypot %}
{% block title %}{% block og_title %}{% if form.event %}Contact au sujet de l'événement {{ form.event.title }}{% else %}
Contact{% endif %}{% endblock %}{% endblock %}
@ -40,6 +41,7 @@ Contact{% endif %}{% endblock %}{% endblock %}
{% endif %}
</header>
<form method="post">{% csrf_token %}
{% render_honeypot_field "alias_name" %}
{{ form.media }}
{{ form.as_p }}
<input type="submit" value="Envoyer">

View File

@ -10,6 +10,9 @@ from django import forms
from django.http import Http404
from django.contrib.postgres.search import SearchQuery, SearchHeadline
from django.utils.safestring import mark_safe
from django.utils.decorators import method_decorator
from honeypot.decorators import check_honeypot
from django.contrib.gis.geos import Point
from django.contrib.gis.measure import D
@ -723,7 +726,7 @@ def export_ical(request):
return response
@method_decorator(check_honeypot, name='post')
class ContactMessageCreateView(SuccessMessageMixin, CreateView):
model = ContactMessage
template_name = "agenda_culturel/contactmessage_create_form.html"

View File

@ -42,4 +42,5 @@ django-location-field==2.7.3
django-robots==6.1
django-debug-toolbar==4.4.6
django-cache-cleaner==0.1.0
emoji==2.14.0
emoji==2.14.0
django-honeypot==1.2.1