From 076a524c272a272045a6d21a959b651aba242c6e Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Fri, 16 Mar 2012 05:05:59 -0400 Subject: fixed a bug in the validation branch of the ask by email handler --- askbot/forms.py | 18 +++++++++++------- askbot/utils/mail.py | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/askbot/forms.py b/askbot/forms.py index 437b7fff..500bedd9 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -618,6 +618,10 @@ class AskForm(forms.Form, FormWithHideableFields): self.cleaned_data['ask_anonymously'] = False return self.cleaned_data['ask_anonymously'] +ASK_BY_EMAIL_SUBJECT_HELP = _( + 'Subject line is expected in the format: ' + '[tag1, tag2, tag3,...] question title' +) class AskByEmailForm(forms.Form): """:class:`~askbot.forms.AskByEmailForm` @@ -640,7 +644,12 @@ class AskByEmailForm(forms.Form): * ``body_text`` - body of question text - a pass-through, no extra validation """ sender = forms.CharField(max_length = 255) - subject = forms.CharField(max_length = 255) + subject = forms.CharField( + max_length = 255, + error_messages = { + 'required': ASK_BY_EMAIL_SUBJECT_HELP + } + ) body_text = QuestionEditorField() def clean_sender(self): @@ -682,12 +691,7 @@ class AskByEmailForm(forms.Form): title = match.group(2).strip() self.cleaned_data['title'] = TitleField().clean(title) else: - raise forms.ValidationError( - _( - 'Subject line is expected in the format: ' - '[tag1, tag2, tag3,...] question title' - ) - ) + raise forms.ValidationError(ASK_BY_EMAIL_SUBJECT_HELP) return self.cleaned_data['subject'] class AnswerForm(forms.Form): diff --git a/askbot/utils/mail.py b/askbot/utils/mail.py index 3d8298d5..795431f8 100644 --- a/askbot/utils/mail.py +++ b/askbot/utils/mail.py @@ -265,9 +265,9 @@ def process_emailed_question(from_address, subject, body, attachments = None): for field_errors in form.errors.values(): error_list.extend(field_errors) - if email_address: + if from_address: bounce_email( - email_address, + from_address, subject, reason = 'problem_posting', body_text = '\n*'.join(error_list) -- cgit v1.2.3-1-g7c22