added signal receiver to send notifications in re amazon-shutdown campaigns

pull/1/head
Andromeda Yelton 2012-08-08 14:22:33 -04:00
parent 8ef30302d4
commit e07f8487ee
1 changed files with 14 additions and 0 deletions

View File

@ -195,6 +195,20 @@ def handle_you_have_pledged(sender, transaction=None, **kwargs):
pledge_created.connect(handle_you_have_pledged)
def handle_wishlist_unsuccessful_amazon(campaign, **kwargs):
"""send notification in response to campaign shutdown following Amazon suspension"""
logger.info('received amazon_suspension signal for {0}'.format(campaign))
# supporters and staff -- though it might be annoying for staff to be getting all these notices!
staff = User.objects.filter(is_staff=True)
supporters = (User.objects.get(id=k) for k in campaign.supporters())
site = Site.objects.get_current()
notification.queue(itertools.chain(staff, supporters), "wishlist_unsuccessful_amazon", {'campaign':campaign, 'site':site}, True)
from regluit.core.tasks import emit_notifications
emit_notifications.delay()
amazon_suspension.connect(handle_wishlist_unsuccessful_amazon)
# The notification templates need some context; I'm making a note of that here
# This can be removed as the relevant functions are written
# RIGHTS_HOLDER_CLAIM_APPROVED: