@@ -0,0 +1,1856 @@
+from __future__ import absolute_import%0A%0Afrom optparse import make_option%0A%0Afrom django.core.management.base import BaseCommand%0A%0Afrom zerver.lib.actions import do_change_enable_digest_emails%0Afrom zerver.models import Realm, UserProfile, get_user_profile_by_email%0A%0Aclass Command(BaseCommand):%0A    help = %22%22%22Turn off digests for a domain or specified set of email addresses.%22%22%22%0A%0A    option_list = BaseCommand.option_list + (%0A        make_option('-d', '--domain',%0A                    dest='domain',%0A                    type='str',%0A                    help='Turn off digests for all users in this domain.'),%0A        make_option('-u', '--users',%0A                    dest='users',%0A                    type='str',%0A                    help='Turn off digests for this comma-separated list of email addresses.'),%0A        )%0A%0A    def handle(self, **options):%0A        if options%5B%22domain%22%5D is None and options%5B%22users%22%5D is None:%0A            self.print_help(%22python manage.py%22, %22turn_off_digests%22)%0A            exit(1)%0A%0A        if options%5B%22domain%22%5D:%0A            realm = Realm.objects.get(domain=options%5B%22domain%22%5D)%0A            user_profiles = UserProfile.objects.filter(realm=realm)%0A        else:%0A            emails = set(%5Bemail.strip() for email in options%5B%22users%22%5D.split(%22,%22)%5D)%0A            user_profiles = %5B%5D%0A            for email in emails:%0A                user_profiles.append(get_user_profile_by_email(email))%0A%0A        print %22Turned off digest emails for:%22%0A        for user_profile in user_profiles:%0A            already_disabled_prefix = %22%22%0A            if user_profile.enable_digest_emails:%0A                do_change_enable_digest_emails(user_profile, False)%0A            else:%0A                already_disabled_prefix = %22(already off) %22%0A            print %22%25s%25s %3C%25s%3E%22 %25 (already_disabled_prefix, user_profile.full_name,%0A                                 user_profile.email)%0A

Add a management command to bulk turn off digests.