update_newsletter_subscribers.py 477 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
from optparse import make_option

from django.core.management.base import BaseCommand, CommandError

from ...models import Subscriber


class Command(BaseCommand):

    def handle(self, verbosity, **kwargs):
        self.verbose = (verbosity > 1)

        for subscriber in Subscriber.objects.filter(is_validated=True).exclude(is_registered=True):
            if self.verbose:
                print 'subscribing', subscriber.email
            subscriber.subscribe_in_mailman()