#!/usr/bin/python

from django.core.management.base import BaseCommand

from zerver.lib.utils import generate_random_token
from zerver.models import Stream

class Command(BaseCommand):
    help = """Set a token for all streams that don't have one."""

    def handle(self, **options):
        streams_needing_tokens = Stream.objects.filter(email_token=None)
        for stream in streams_needing_tokens:
            stream.email_token = generate_random_token(32)
            stream.save()

Add a management command to generate hashes for all streams that need them.
Add a management command to generate hashes for all streams that need them.

(imported from commit b3a05e47dfe69b44f984185e360d79bf04f7885b)
