diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2011-04-14 13:43:34 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2011-04-14 13:43:34 -0400 |
commit | 73dd719640f4aa3efb71da03f058553ee90bf7d2 (patch) | |
tree | 2c981bbec47076f45ceea27b177272c6dcdf8314 | |
parent | 94caa1ed2512cb54fb8d79f302b3c8c432a97094 (diff) | |
download | askbot-73dd719640f4aa3efb71da03f058553ee90bf7d2.tar.gz askbot-73dd719640f4aa3efb71da03f058553ee90bf7d2.tar.bz2 askbot-73dd719640f4aa3efb71da03f058553ee90bf7d2.zip |
fixed bugs in post_emailed_questions as suggested by Benoit
-rw-r--r-- | askbot/management/commands/post_emailed_questions.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/askbot/management/commands/post_emailed_questions.py b/askbot/management/commands/post_emailed_questions.py index b80eb188..73b5ed3e 100644 --- a/askbot/management/commands/post_emailed_questions.py +++ b/askbot/management/commands/post_emailed_questions.py @@ -125,7 +125,7 @@ class Command(NoArgsCommand): all messages are deleted thereafter """ - if askbot_settings.ALLOW_ASKING_BY_EMAIL: + if not askbot_settings.ALLOW_ASKING_BY_EMAIL: raise CommandError('Asking by email is not enabled') #open imap server and select the inbox @@ -146,6 +146,12 @@ class Command(NoArgsCommand): #get message ids status, ids = imap.search(None, 'ALL') + if len(ids[0].strip()) == 0: + #with empty inbox - close and exit + imap.close() + imap.logout() + return + #for each id - read a message, parse it and post a question for id in ids[0].split(' '): t, data = imap.fetch(id, '(RFC822)') @@ -166,8 +172,9 @@ class Command(NoArgsCommand): if form.is_valid(): email_address = form.cleaned_data['email'] try: - print 'looking for ' + email_address - user = models.User.objects.get(email = email_address) + user = models.User.objects.get( + email__iexact = email_address + ) except models.User.DoesNotExist: bounce_email(email_address, subject, reason = 'unknown_user') except models.User.MultipleObjectsReturned: @@ -178,10 +185,6 @@ class Command(NoArgsCommand): body_text = form.cleaned_data['body_text'] try: - print 'posting question' - print title - print tagnames - print body_text user.post_question( title = title, tags = tagnames, |