patched notification into celery

not sure where to put emit_notifications task; couldn't get it to work
in tasks because of circular imports [start #27115145]
pull/1/head
eric 2012-03-29 16:13:36 -04:00
parent caae736432
commit ec35e27b52
1 changed files with 11 additions and 4 deletions

View File

@ -7,6 +7,8 @@ from social_auth.signals import pre_update
from social_auth.backends.facebook import FacebookBackend
from tastypie.models import create_api_key
#from regluit.core import tasks
import registration.signals
import logging
@ -60,6 +62,12 @@ from django.utils.translation import ugettext_noop as _
from django.db.models import signals
from notification import models as notification
from notification.engine import send_all
from celery.decorators import task
@task
def emit_notifications():
send_all()
# create notification types (using django-notification) -- tie to syncdb
@ -75,9 +83,8 @@ from django.contrib.comments.signals import comment_was_posted
def notify_comment(comment, request, **kwargs):
other_commenters = User.objects.filter(comment_comments__content_type=comment.content_type, comment_comments__object_pk=comment.object_pk).distinct().exclude(id=comment.user.id)
other_wishers = comment.content_object.wished_by().exclude(id=comment.user.id).exclude(id__in=other_commenters)
notification.send(other_commenters, "coment_on_commented", {'comment':comment}, True)
notification.send(other_wishers, "wishlist_comment", {'comment':comment}, True)
notification.queue(other_commenters, "coment_on_commented", {'comment':comment}, True)
notification.queue(other_wishers, "wishlist_comment", {'comment':comment}, True)
emit_notifications.delay()
comment_was_posted.connect(notify_comment)