Skip to content
This repository
Browse code

Bug fixes to the previous commit.

  • Loading branch information...
commit 3840ddafbbfedbc38753ab97895ba05acb01db4b 1 parent 69a57f6
Federico Capoano nemesisdesign authored
5 math_captcha/fields.py
... ... @@ -1,7 +1,7 @@
1 1 from django.forms.fields import IntegerField
2 2 from django.forms.widgets import TextInput
3 3 from util import question, encode
4   -
  4 +import settings
5 5
6 6 class MathWidget(TextInput):
7 7 """
@@ -9,9 +9,10 @@ class MathWidget(TextInput):
9 9 """
10 10 def render(self, name, value, attrs):
11 11 aquestion = question()
  12 + label = '%s %s ?' % (settings.QUESTION, aquestion)
12 13 value = super(MathWidget, self).render(name, value, attrs)
13 14 hidden = '<input type="hidden" value="%s" name="math_captcha_question"/>' % encode(aquestion)
14   - return value.replace('<input', '%s %s = <input' % (hidden, aquestion))
  15 + return value.replace('<input', '%s %s = <input' % (hidden, label))
15 16
16 17 class MathField(IntegerField):
17 18 widget = MathWidget()
2  math_captcha/forms.py 100644 → 100755
@@ -65,6 +65,6 @@ class MyForm(MathCaptchaForm):
65 65 math_captcha_field = MathField(label=settings.QUESTION)
66 66 math_captcha_question = forms.fields.CharField(widget=NullWidget())
67 67
68   - def clean(self):
  68 + def clean_math_captcha_field(self):
69 69 super(MathCaptchaForm, self).clean()
70 70 math_clean(self)
2  math_captcha/util.py
@@ -12,7 +12,7 @@ def question():
12 12 # avoid negative answers
13 13 n1, n2 = n2, n1
14 14
15   - return "%s %s %s %s ?" % (settings.QUESTION, n1, choice(settings.OPERATORS), n2)
  15 + return "%s %s %s" % (n1, choice(settings.OPERATORS), n2)
16 16
17 17 def encode(question):
18 18 """
8 nodeshot/templates/ajax/contact.html
... ... @@ -1,7 +1,7 @@
1 1 <div class="dialog-form ui-widget" >
2 2 <form id="node-form" class="ui-corner-all ui-widget-content" method="post" action="">
3 3 <h1>Contatta il nodo {{ node.name }}</h1>
4   - <p>I campi contrassegnati con un asterisco sono obbligatori.</p>
  4 + <p>Tutti i campi sono obbligatori.</p>
5 5 <fieldset>
6 6 {% csrf_token %}
7 7 {% if form.non_field_errors %}
@@ -11,7 +11,7 @@
11 11 {% endif %}
12 12
13 13 <div class="fieldWrapper">
14   - <label for="id_name">Tuo nome: <big>*</big><label>
  14 + <label for="id_name">Tuo nome:<label>
15 15 {% if form.name.errors %}
16 16 <div class="ui-state-error">
17 17 {{ form.name.errors }}
@@ -21,7 +21,7 @@
21 21 </div>
22 22
23 23 <div class="fieldWrapper">
24   - <label for="id_email">Email: <big>*</big><label>
  24 + <label for="id_email">Email:<label>
25 25 {% if form.email.errors %}
26 26 <div class="ui-state-error">
27 27 {{ form.email.errors }}
@@ -31,7 +31,7 @@
31 31 </div>
32 32
33 33 <div class="fieldWrapper">
34   - <label for="id_text">Testo: <big>*</big><label>
  34 + <label for="id_text">Testo:<label>
35 35 {% if form.text.errors %}
36 36 <div class="ui-state-error">
37 37 {{ form.text.errors }}
2  nodeshot/views.py
@@ -264,7 +264,7 @@ def contact(request, node_id):
264 264 if form.is_valid():
265 265 pass
266 266
267   - ### TODO: Captcha ###
  267 + ### TODO: need to be stored in the database ###
268 268
269 269 # if form has NOT been submitted
270 270 else:

0 comments on commit 3840dda

Please sign in to comment.
Something went wrong with that request. Please try again.