Mercurial > public > sg101
diff gpp/forums/views/subscriptions.py @ 522:82b97697312e
Created Celery tasks to process new posts and topics. Keep the updated topic set in Redis.
This is for tickets #194, #237, #239.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 18 Dec 2011 23:46:52 +0000 |
parents | 9d3bd7304050 |
children |
line wrap: on
line diff
--- a/gpp/forums/views/subscriptions.py Sat Dec 17 23:43:00 2011 +0000 +++ b/gpp/forums/views/subscriptions.py Sun Dec 18 23:46:52 2011 +0000 @@ -18,13 +18,14 @@ from core.paginator import DiggPaginator -def notify_topic_subscribers(post): +def notify_topic_subscribers(post, defer=True): """ The argument post is a newly created post. Send out an email notification to all subscribers of the post's parent Topic. + + The defer flag is passed to core.functions.send_mail. If True, the mail is + sent on a Celery task. If False, the mail is sent on the caller's thread. """ - #TODO: consider moving this function of the HTTP request/response cycle. - topic = post.topic recipients = topic.subscribers.exclude(id=post.user.id).values_list( 'email', flat=True) @@ -43,7 +44,8 @@ 'unsubscribe_url': unsubscribe_url, }) for recipient in recipients: - send_mail(subject, msg, settings.DEFAULT_FROM_EMAIL, [recipient]) + send_mail(subject, msg, settings.DEFAULT_FROM_EMAIL, [recipient], + defer=defer) @login_required