{% load i18n %}
+
<h1>{{ title }}</h1>
<form action="{{ request.get_full_path }}" method="post" accept-charset="utf-8"
class="cuteform{% if placeholdize %} hidelabels{% endif %}">
+{% csrf_token %}
+{% if honeypot %}
+ {% load honeypot %}
+ {% render_honeypot_field %}
+{% endif %}
<ol>
<div id="id_{% if form_prefix %}{{ form_prefix }}-{% endif %}__all__"></div>
{{ form.as_ul }}
from django.utils import simplejson
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.vary import vary_on_headers
+from honeypot.decorators import verify_honeypot_value
class LazyEncoder(simplejson.JSONEncoder):
formname = "form"
form_prefix = None
full_template = "ajaxable/form_on_page.html"
+ honeypot = False
@method_decorator(vary_on_headers('X-Requested-With'))
def __call__(self, request, *args, **kwargs):
form_kwargs['prefix'] = self.form_prefix
if request.method == "POST":
+ if self.honeypot:
+ response = verify_honeypot_value(request, None)
+ if response:
+ return response
+
# do I need to be logged in?
if self.POST_login and not request.user.is_authenticated():
return require_login(request)
context = {
self.formname: form,
"title": title,
+ "honeypot": self.honeypot,
"placeholdize": self.placeholdize,
"submit": self.submit,
"response_data": response_data,
</div>
<div class="if-unlike">
<form id="social-like-book-{{ book.slug }}" data-callback='social-like-book' method='post' class='ajax-form' action='{% url social_like_book book.slug %}'>
+ {% csrf_token %}
<button type='submit'>☆</button>
</form>
</div>
form_class = forms.CustomPDFForm
title = ugettext_lazy('Download custom PDF')
submit = ugettext_lazy('Download')
+ honeypot = True
def __call__(self, request):
from copy import copy
<form action="{% url social_unlike_book view_kwargs.slug %}" method="post" accept-charset="utf-8"
class="cuteform{% if placeholdize %} hidelabels{% endif %}">
+{% csrf_token %}
<input type="submit" value="{% trans "Remove from my shelf" %}"/>
</form>
<form action="{{ request.get_full_path }}" method="post" accept-charset="utf-8"
class="cuteform{% if placeholdize %} hidelabels{% endif %}">
+{% csrf_token %}
<ol>
<div id="id___all__"></div>
{{ form.as_ul }}
{% load i18n %}
+{% load honeypot %}
+
<h1>{% trans "Didn't find a book? Make a suggestion." %}</h1>
<form id='suggest-publishing-form' action="{% url suggest_publishing %}" method="post" accept-charset="utf-8" class="cuteform">
{% csrf_token %}
+{% render_honeypot_field %}
<ol>
<li><span class="error">{{ form.contact.errors }}</span><label for="id_contact">{{ form.contact.label }}</label> {{ form.contact }}</li>
from ajaxable.utils import AjaxableFormView
from suggest import forms
-from suggest.models import Suggestion, PublishingSuggestion
class PublishingSuggestionFormView(AjaxableFormView):
title = _('Report a bug or suggestion')
template = "publishing_suggest.html"
success_message = _('Report was sent successfully.')
+ honeypot = True
class SuggestionFormView(AjaxableFormView):
title = _('Report a bug or suggestion')
submit = _('Send report')
success_message = _('Report was sent successfully.')
+ honeypot = True
</div>
{% else %}
{% if waiting %}
- <h1>{% trans "Your file is being prepared, please wait." %}</h1>
+ <h1><img src="{{ STATIC_URL }}img/indicator.gif" alt="{% trans 'Please wait' %}"/>
+ {% trans "Your file is being prepared, please wait." %}</h1>
<div class="normal-text">
<p>{% blocktrans with d=waiting.description %}The file you requested was: <em>{{d}}</em>.{% endblocktrans %}</p>
{% block content %}
<form action="{% url import_book %}" method="post" enctype="multipart/form-data">
+ {% csrf_token %}
<p><input type="file" id="id_book_xml_file" name="book_xml_file" /> <input type="submit" value="{% trans "Import book" %}"/></p>
</form>
{{ block.super }}
<form action="{{ request.get_full_path }}" method="post" accept-charset="utf-8"
class="cuteform{% if placeholdize %} hidelabels{% endif %}">
+{% csrf_token %}
<ol>
<div id="id_{% if form_prefix %}{{ form_prefix }}-{% endif %}__all__"></div>
{{ form.as_ul }}
{% extends "auth/login.html" %}
{% load i18n %}
+{% load honeypot %}
{% block extra %}
<form action="{% url register %}" method="post" accept-charset="utf-8"
class="cuteform hidelabels">
+{% csrf_token %}
+{% honeypot_render_field %}
<ol>
<div id="id_register-__all__"></div>
{{ register_form.as_ul }}
<p>{% blocktrans %}Confirm to authorize access to Wolne Lektury as user <strong>{{ user}}</strong>.{% endblocktrans %}</p>
<form action="{% url piston.authentication.oauth_user_auth %}" method="POST">
+ {% csrf_token %}
{{ form.as_p }}
<button type="submit">Confirm</button>
</form>
<div id="lang-menu-items">
{% for lang in LANGUAGES %}
<form action="{% url django.views.i18n.set_language %}" method="post">
+ {% csrf_token %}
<input type="hidden" name="language" value="{{ lang.0 }}" />
<button type="submit"
class="{% ifequal lang.0 LANGUAGE_CODE %}active{% endifequal %} mono"
submit = _('Register')
ajax_redirect = True
form_prefix = 'register'
+ honeypot = True
def __call__(self, request):
if request.user.is_authenticated():
django-piston
django-jsonfield
django-allauth
+django-honeypot
python-memcached
piwik
from settings.auth import *
from settings.cache import *
from settings.celery import *
+from settings.contrib import *
from settings.custom import *
from settings.locale import *
from settings.static import *
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'pagination.middleware.PaginationMiddleware',
ROOT_URLCONF = 'wolnelektury.urls'
INSTALLED_APPS = [
+ 'wolnelektury_core',
# external
'django.contrib.auth',
'django.contrib.contenttypes',
'sorl.thumbnail',
'djcelery',
'djkombu',
+ 'honeypot',
# 'django_nose',
#allauth stuff
'modeltranslation',
# our
- 'wolnelektury_core',
'ajaxable',
'api',
'catalogue',
--- /dev/null
+HONEYPOT_FIELD_NAME = 'miut'