Browse Source

add captcha validation for the nomination form

David Beltra 7 months ago
parent
commit
e1bf05493c

+ 2
- 0
apps/nominations/forms.py View File

@@ -1,9 +1,11 @@
1 1
 from django import forms
2 2
 from django.forms import ModelForm
3
+from captcha.fields import CaptchaField
3 4
 from django.utils.translation import gettext_lazy as _
4 5
 from .models import Nomination
5 6
 
6 7
 class NominationForm(ModelForm):
8
+    captcha = CaptchaField()
7 9
     class Meta:
8 10
         model = Nomination
9 11
         fields = ['nominated', 'reasons_nomination', 'name', 'email', 'sk', 'dg', 'pep', 'ccc']

+ 1
- 1
apps/nominations/templates/pages/nominierungen.html View File

@@ -48,7 +48,7 @@
48 48
         {% endif %}
49 49
         {% nevercache %}
50 50
             {% if field.errors %}
51
-                <p class="alert alert-error">{{field.errors}}</p>
51
+                <div class="alert alert-error">{{field.errors}}</div>
52 52
             {% endif %}
53 53
         {% endnevercache %}
54 54
     </div>

+ 1
- 0
bigbrother/settings.py View File

@@ -263,6 +263,7 @@ INSTALLED_APPS = (
263 263
     "mezzanine.twitter",
264 264
     # "mezzanine.accounts",
265 265
 
266
+    "captcha",
266 267
     "apps.blocks",
267 268
     "apps.components.button",
268 269
     "apps.components.icon",

+ 3
- 1
bigbrother/urls.py View File

@@ -16,7 +16,9 @@ import os
16 16
 
17 17
 admin.autodiscover()
18 18
 
19
-urlpatterns = []
19
+urlpatterns = [
20
+    url(r'^captcha/', include('captcha.urls')),
21
+]
20 22
 
21 23
 # Add the urlpatterns for any custom Django applications here.
22 24
 # You can also change the ``home`` view to add your own functionality

Loading…
Cancel
Save