From 2121965a8cce50d797ba70438f3a936085fe32a1 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Fri, 7 Apr 2017 16:05:53 +0200 Subject: [PATCH] honeypot for spambots --- redakcja/settings/common.py | 2 ++ redakcja/templates/registration.html | 2 ++ redakcja/views.py | 3 +++ requirements.txt | 1 + 4 files changed, 8 insertions(+) diff --git a/redakcja/settings/common.py b/redakcja/settings/common.py index cad0951c..83e720df 100644 --- a/redakcja/settings/common.py +++ b/redakcja/settings/common.py @@ -127,6 +127,7 @@ INSTALLED_APPS = ( 'modeltranslation', 'constance', 'constance.backends.database', + 'honeypot', 'catalogue', # 'cover', @@ -170,6 +171,7 @@ SHOW_APP_VERSION = False FORMS_BUILDER_EDITABLE_SLUGS = True FORMS_BUILDER_LABEL_MAX_LENGTH = 2048 +HONEYPOT_FIELD_NAME = 'miut' try: from redakcja.settings.compress import * diff --git a/redakcja/templates/registration.html b/redakcja/templates/registration.html index 3b9a9835..43a8c393 100644 --- a/redakcja/templates/registration.html +++ b/redakcja/templates/registration.html @@ -1,5 +1,6 @@ {% extends "catalogue/base.html" %} {% load i18n %} +{% load honeypot %} {% block content %}
@@ -11,6 +12,7 @@
{% csrf_token %} {{ form.non_field_errors }} + {% render_honeypot_field %} {{ form.first_name.errors }} diff --git a/redakcja/views.py b/redakcja/views.py index 07c6d65b..948a374e 100644 --- a/redakcja/views.py +++ b/redakcja/views.py @@ -7,6 +7,8 @@ from django.shortcuts import render, redirect from django.contrib.auth import authenticate, login from django.contrib.auth.models import User from django.core.mail import send_mail +from honeypot.decorators import check_honeypot + from .forms import RegistrationForm from catalogue.models import Document from organizations.models import Organization @@ -33,6 +35,7 @@ def main(request): }) +@check_honeypot def register(request): if request.method == 'POST': form = RegistrationForm(request.POST, request.FILES) diff --git a/requirements.txt b/requirements.txt index ecfa9a0a..5ef9001d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,6 +25,7 @@ jsonfield django-email-extras django-modeltranslation>=0.12,<0.13 django-constance[database] +django-honeypot celery>=3.1.12,<3.2 kombu>3.0,<3.1 -- 2.20.1