diff --git a/apps/review/forms.py b/apps/review/forms.py index 48b31a1c..b72a1735 100644 --- a/apps/review/forms.py +++ b/apps/review/forms.py @@ -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'Отзыв')}) + } diff --git a/apps/review/templatetags/__init__.py b/apps/review/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/apps/review/templatetags/review_tags.py b/apps/review/templatetags/review_tags.py new file mode 100644 index 00000000..c16176f3 --- /dev/null +++ b/apps/review/templatetags/review_tags.py @@ -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() diff --git a/proj/settings.py b/proj/settings.py index c781bae0..63f364c6 100644 --- a/proj/settings.py +++ b/proj/settings.py @@ -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: diff --git a/requirements.txt b/requirements.txt index 14f6d5b2..ee9cf97e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/templates/client/blank.html b/templates/client/blank.html index cae0698c..eab5ae20 100644 --- a/templates/client/blank.html +++ b/templates/client/blank.html @@ -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, + {% block head_scripts %}{% endblock %} @@ -222,7 +224,9 @@ This template include basic anf main styles and js files,

{% trans 'Оставьте отзыв о работе сайта или предложение об его улучшении' %}.

- + {% site_review_form as sr_form %} + {{ sr_form.review }} + {{ sr_form.captcha }}