]> git.openstreetmap.org Git - osqa.git/commitdiff
Finished Issue 313
authorqw3rty <qw3rty@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 11 Jun 2010 20:57:08 +0000 (20:57 +0000)
committerqw3rty <qw3rty@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 11 Jun 2010 20:57:08 +0000 (20:57 +0000)
Adding a bunch of non-breaking spaces to the text so the minimum length of questions, answers, and comments can be bypassed is not possable anymore.

git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@410 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/forms/qanda.py

index 7c58500975faca4b1f031ccf46948440e7a23224..b4b55ce847b2dcf378862bbc2a83b9a3c8e82d7b 100644 (file)
@@ -42,7 +42,7 @@ class QuestionEditorField(EditorField):
 
 
     def clean(self, value):
-        if self.required and (len(value) < settings.FORM_MIN_QUESTION_BODY):
+        if self.required and (len(re.sub('[ ]{2,}', ' ', value)) < settings.FORM_MIN_QUESTION_BODY):
             raise forms.ValidationError(_('question content must be at least %s characters') % settings.FORM_MIN_QUESTION_BODY)
 
         return value
@@ -53,7 +53,7 @@ class AnswerEditorField(EditorField):
         self.required = True
 
     def clean(self, value):
-        if len(value) < settings.FORM_MIN_QUESTION_BODY:
+        if len(re.sub('[ ]{2,}', ' ', value)) < settings.FORM_MIN_QUESTION_BODY:
             raise forms.ValidationError(_('answer content must be at least %s characters') % settings.FORM_MIN_QUESTION_BODY)
 
         return value