we are going to need an unsuccessful campaign signal asap, sadly

pull/1/head
Andromeda Yelton 2012-06-28 14:07:33 -07:00
parent eda96f716b
commit de929363e5
5 changed files with 30 additions and 4 deletions

View File

@ -230,6 +230,7 @@ class Campaign(models.Model):
self.status = 'UNSUCCESSFUL'
action = CampaignAction(campaign=self, type='failed', comment = self.current_total)
action.save()
regluit.core.signals.unsuccessful_campaign.send(sender=None,campaign=self)
self.save()
return True
else:

View File

@ -138,6 +138,23 @@ def notify_successful_campaign(campaign, **kwargs):
# successful_campaign -> send notices
successful_campaign.connect(notify_successful_campaign)
unsuccessful_campaign = Signal(providing_args=["campaign"])
def notify_unsuccessful_campaign(campaign, **kwargs):
"""send notification in response to unsuccessful campaign"""
logger.info('received unsuccessful_campaign 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", {'campaign':campaign, 'site':site}, True)
from regluit.core.tasks import emit_notifications
emit_notifications.delay()
# unsuccessful_campaign -> send notices
unsuccessful_campaign.connect(notify_successful_campaign)
def handle_transaction_charged(sender,transaction=None, **kwargs):
if transaction==None:
return

View File

@ -1,9 +1,15 @@
Alas. The campaign to unglue {{ campaign.work.title}} (https://{{site.domain}}{% url work campaign.work.id %}) has not succeeded.
{% with campaign.work.title as title %}
{% with campaign.rightsholder as rightsholder %}
Alas. The campaign to unglue {{ title }} (https://{{site.domain}}{% url work campaign.work.id %}) has not succeeded.
If you pledged toward this work, your pledge will expire shortly and your credit card will not be charged, nor will you receive any premiums.
Still want to give {{ campaign.work.title }} to the world? Don't despair. Keep it on your wishlist and tell everyone why you love this book. The rights holder, {{ campaign.rightsholder }}, may run a campaign with different terms in the future. With your help, we may yet be able to unglue {{ campaign.work.title }}.
Still want to give {{ title }} to the world? Don't despair. Keep it on your wishlist and tell everyone why you love this book. The rights holder, {{ rightsholder }}, may run a campaign with different terms in the future. With your help, we may yet be able to unglue {{ title }}.
There are also other books with active campaigns that need your help: https://unglue.it/campaigns/ending .
Thank you for your support.
{{ campaign.rightsholder }} (rights holder for {{ campaign.work.title }} and the Unglue.it team
{{ rightsholder }} (rights holder for {{ title }}) and the Unglue.it team
{% endwith %}{% endwith %}

View File

@ -14,6 +14,8 @@
Still want to give {{ title }} to the world? Don't despair. Keep it on your wishlist and tell everyone why you love this book. The rights holder, {{ campaign.rightsholder }}, may run a campaign with different terms in the future. With your help, we may yet be able to unglue {{ title }}.
There are also <a href="https://unglue.it/campaigns/ending">other books with active campaigns</a> that need your help.
Thank you for your support.
</div>
</div>

View File

@ -1 +1 @@
Alas: the campaign for {{ campaign.work.title }} has not succeeded
Alas: the Unglue.it campaign for {{ campaign.work.title }} has not succeeded