From 4e24b432c445f6a5c99dde62659f2e24fce591d5 Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Fri, 14 Feb 2014 10:36:20 -0500 Subject: [PATCH] [manual] Add script to migrate subs to new stream notification settings. Previously, streams used `notifications`. Now they have separate `desktop_notifications` and `audible_notifications`. On staging, this should be run after the schema migration has been applied (and technically before the code that uses the new fields is deployed, but for staging, processing our notification settings a few minutes late won't hurt anyone). On prod, the script should be re-run just before the code using the new notification settings is deployed to process any customer notification settings changed since the staging deploy. (imported from commit d99d238cd1b317c5180d7f940d70a7e2f8f9c712) --- .../commands/migrate_stream_notifications.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 zilencer/management/commands/migrate_stream_notifications.py diff --git a/zilencer/management/commands/migrate_stream_notifications.py b/zilencer/management/commands/migrate_stream_notifications.py new file mode 100644 index 0000000000..3014ae21ab --- /dev/null +++ b/zilencer/management/commands/migrate_stream_notifications.py @@ -0,0 +1,14 @@ +from __future__ import absolute_import + +from django.core.management.base import BaseCommand +from zerver.models import Subscription + +class Command(BaseCommand): + help = """One-off script to migration users' stream notification settings.""" + + def handle(self, *args, **options): + for subscription in Subscription.objects.all(): + subscription.desktop_notifications = subscription.notifications + subscription.audible_notifications = subscription.notifications + subscription.save(update_fields=["desktop_notifications", + "audible_notifications"])