regluit/core/management/commands/fail_campaign_amazon.py

20 lines
669 B
Python
Raw Normal View History

"""
print user emails
"""
from django.core.management.base import BaseCommand
2013-06-03 16:31:39 +00:00
from regluit.core import models, signals
class Command(BaseCommand):
help = "set active campaigns to unsuccessful"
def handle(self, **options):
for campaign in models.Campaign.objects.filter(status='ACTIVE'):
campaign.status = 'UNSUCCESSFUL'
campaign.save()
action = models.CampaignAction(campaign=campaign, type='failed', comment = 'amazon suspension')
action.save()
signals.amazon_suspension.send(sender=None,campaign=campaign)
print 'campaign %s set to UNSUCCESSFUL' % campaign.id