added recaptcha

remotes/origin/HEAD
Slava Kyrachevsky 9 years ago
parent 5597af9914
commit a264fd12b1
  1. 8
      apps/review/forms.py
  2. 0
      apps/review/templatetags/__init__.py
  3. 14
      apps/review/templatetags/review_tags.py
  4. 6
      proj/settings.py
  5. 1
      requirements.txt
  6. 6
      templates/client/blank.html

@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
from django import forms
from django.utils.translation import ugettext_lazy as _
from .models import Review, SiteReview
from captcha.fields import ReCaptchaField
class ReviewCreateForm(forms.ModelForm):
"""
@ -28,6 +31,11 @@ class SiteReviewForm(forms.ModelForm):
"""
Форма для отзывов о сайте и предложений по улучшению
"""
captcha = ReCaptchaField(attrs={'theme': 'clean'})
class Meta:
model = SiteReview
exclude = ()
widgets = {
'review': forms.Textarea(attrs={'placeholder': _(u'Отзыв')})
}

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
from django.template import Library
from ..forms import SiteReviewForm
register = Library()
@register.assignment_tag
def site_review_form():
"""
Форма для отзывов о сайте и предложений по улучшению
"""
return SiteReviewForm()

@ -398,6 +398,7 @@ INSTALLED_APPS = (
'south',
'rosetta',
'widget_tweaks',
'captcha',
)
CRONJOBS = [
@ -504,6 +505,11 @@ PERIODIC = {
9: _(u'Раз в 5 лет')
}
# captcha
RECAPTCHA_PUBLIC_KEY = '6LffshgUAAAAALQSBrZusJgfqNsREZbiL9ZT4Jlv'
RECAPTCHA_PRIVATE_KEY = '6LffshgUAAAAAF7zZnMbONB36CmOueKKD097UvMg'
NOCAPTCHA = True
try:
from proj.local import *
except ImportError, e:

@ -15,6 +15,7 @@ django-haystack==2.3.2
django-hvad==1.2.0
django-model-utils==2.2
django-modeltranslation==0.12
django-recaptcha==1.2.1
django-redis==4.0.0
django-redis-cache==0.13.1
django-rosetta==0.7.6

@ -2,6 +2,7 @@
{% load i18n %}
{% load template_filters %}
{% load tempalte_tags %}
{% load review_tags %}
{% get_current_language as LANGUAGE_CODE %}
{% comment %}
@ -49,6 +50,7 @@ This template include basic anf main styles and js files,
<script src="{% static 'client/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js' %}"></script>
<script src="{% static 'client/js/vendor/jquery-1.10.1.min.js' %}"></script>
<script src="{% static 'client/js/jquery-ui-1.10.4.custom.min.js' %}" type="text/javascript"></script>
<script type="text/javascript" src="https://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
{% block head_scripts %}{% endblock %}
@ -222,7 +224,9 @@ This template include basic anf main styles and js files,
<div class="form_data">
<p>{% trans 'Оставьте отзыв о работе сайта или предложение об его улучшении' %}.</p>
<textarea name="review" id="id_review" placeholder="{% trans 'Отзыв' %}"></textarea>
{% site_review_form as sr_form %}
{{ sr_form.review }}
{{ sr_form.captcha }}
<button class="button">{% trans 'Отправить' %}</button>
</div>

Loading…
Cancel
Save