X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/9308d78c7f1e4d2a4faf3b98d1b24c262f3b6287..0a3506ef33141207e7e879fe763dc3adacbc591e:/forum/forms/qanda.py diff --git a/forum/forms/qanda.py b/forum/forms/qanda.py index 7c58500..d54eabb 100644 --- a/forum/forms/qanda.py +++ b/forum/forms/qanda.py @@ -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 @@ -78,14 +78,16 @@ class TagNamesField(forms.CharField): data = value.strip().lower() split_re = re.compile(r'[ ,]+') - list = split_re.split(data) + list = {} + for tag in split_re.split(data): + list[tag] = tag if len(list) > settings.FORM_MAX_NUMBER_OF_TAGS or len(list) < settings.FORM_MIN_NUMBER_OF_TAGS: raise forms.ValidationError(_('please use between %(min)s and %(max)s tags') % { 'min': settings.FORM_MIN_NUMBER_OF_TAGS, 'max': settings.FORM_MAX_NUMBER_OF_TAGS}) list_temp = [] tagname_re = re.compile(r'^[\w+\.-]+$', re.UNICODE) - for tag in list: + for key,tag in list.items(): if len(tag) > settings.FORM_MAX_LENGTH_OF_TAG or len(tag) < settings.FORM_MIN_LENGTH_OF_TAG: raise forms.ValidationError(_('please use between %(min)s and %(max)s characters in you tags') % { 'min': settings.FORM_MIN_LENGTH_OF_TAG, 'max': settings.FORM_MAX_LENGTH_OF_TAG}) if not tagname_re.match(tag): @@ -134,7 +136,7 @@ class SummaryField(forms.CharField): class FeedbackForm(forms.Form): name = forms.CharField(label=_('Your name:'), required=False) - email = forms.EmailField(label=_('Email (not shared with anyone):'), required=False) + email = forms.EmailField(label=_('Email (not shared with anyone):'), required=True) message = forms.CharField(label=_('Your message:'), max_length=800,widget=forms.Textarea(attrs={'cols':60})) next = NextUrlField()