summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-03-16 05:05:59 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-03-16 05:05:59 -0400
commit076a524c272a272045a6d21a959b651aba242c6e (patch)
treeaf738a7779378d193f540b198d0e067cd81bd8f9
parent49f0e7d503eb83c1359ba6f90d68fc5e38ec5300 (diff)
downloadaskbot-076a524c272a272045a6d21a959b651aba242c6e.tar.gz
askbot-076a524c272a272045a6d21a959b651aba242c6e.tar.bz2
askbot-076a524c272a272045a6d21a959b651aba242c6e.zip
fixed a bug in the validation branch of the ask by email handler
-rw-r--r--askbot/forms.py18
-rw-r--r--askbot/utils/mail.py4
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)