Skip to content
Browse files

Bug fixes to the previous commit.

  • Loading branch information...
1 parent 69a57f6 commit 3840ddafbbfedbc38753ab97895ba05acb01db4b nemesisdesign committed Aug 1, 2011
Showing with 10 additions and 9 deletions.
  1. +3 −2 math_captcha/fields.py
  2. +1 −1 math_captcha/forms.py
  3. +1 −1 math_captcha/util.py
  4. +4 −4 nodeshot/templates/ajax/contact.html
  5. +1 −1 nodeshot/views.py
View
5 math_captcha/fields.py
@@ -1,17 +1,18 @@
from django.forms.fields import IntegerField
from django.forms.widgets import TextInput
from util import question, encode
-
+import settings
class MathWidget(TextInput):
"""
Text input for a math captcha field. Stores hashed answer in hidden ``math_captcha_question`` field
"""
def render(self, name, value, attrs):
aquestion = question()
+ label = '%s %s ?' % (settings.QUESTION, aquestion)
value = super(MathWidget, self).render(name, value, attrs)
hidden = '<input type="hidden" value="%s" name="math_captcha_question"/>' % encode(aquestion)
- return value.replace('<input', '%s %s = <input' % (hidden, aquestion))
+ return value.replace('<input', '%s %s = <input' % (hidden, label))
class MathField(IntegerField):
widget = MathWidget()
View
2 math_captcha/forms.py 100644 → 100755
@@ -65,6 +65,6 @@ class MyForm(MathCaptchaForm):
math_captcha_field = MathField(label=settings.QUESTION)
math_captcha_question = forms.fields.CharField(widget=NullWidget())
- def clean(self):
+ def clean_math_captcha_field(self):
super(MathCaptchaForm, self).clean()
math_clean(self)
View
2 math_captcha/util.py
@@ -12,7 +12,7 @@ def question():
# avoid negative answers
n1, n2 = n2, n1
- return "%s %s %s %s ?" % (settings.QUESTION, n1, choice(settings.OPERATORS), n2)
+ return "%s %s %s" % (n1, choice(settings.OPERATORS), n2)
def encode(question):
"""
View
8 nodeshot/templates/ajax/contact.html
@@ -1,7 +1,7 @@
<div class="dialog-form ui-widget" >
<form id="node-form" class="ui-corner-all ui-widget-content" method="post" action="">
<h1>Contatta il nodo {{ node.name }}</h1>
- <p>I campi contrassegnati con un asterisco sono obbligatori.</p>
+ <p>Tutti i campi sono obbligatori.</p>
<fieldset>
{% csrf_token %}
{% if form.non_field_errors %}
@@ -11,7 +11,7 @@
{% endif %}
<div class="fieldWrapper">
- <label for="id_name">Tuo nome: <big>*</big><label>
+ <label for="id_name">Tuo nome:<label>
{% if form.name.errors %}
<div class="ui-state-error">
{{ form.name.errors }}
@@ -21,7 +21,7 @@
</div>
<div class="fieldWrapper">
- <label for="id_email">Email: <big>*</big><label>
+ <label for="id_email">Email:<label>
{% if form.email.errors %}
<div class="ui-state-error">
{{ form.email.errors }}
@@ -31,7 +31,7 @@
</div>
<div class="fieldWrapper">
- <label for="id_text">Testo: <big>*</big><label>
+ <label for="id_text">Testo:<label>
{% if form.text.errors %}
<div class="ui-state-error">
{{ form.text.errors }}
View
2 nodeshot/views.py
@@ -264,7 +264,7 @@ def contact(request, node_id):
if form.is_valid():
pass
- ### TODO: Captcha ###
+ ### TODO: need to be stored in the database ###
# if form has NOT been submitted
else:

0 comments on commit 3840dda

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