From 1ca2f6fa7f07bd043b2d27f5313fa7218700a502 Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Mon, 18 Mar 2013 15:46:31 -0400 Subject: [PATCH] Add a management command to reset your stream colors to the default. (imported from commit f6891ad40088bf34686a7d8a2d910a9a0f3be7c2) --- zephyr/management/commands/reset_colors.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 zephyr/management/commands/reset_colors.py diff --git a/zephyr/management/commands/reset_colors.py b/zephyr/management/commands/reset_colors.py new file mode 100644 index 0000000000..0729be4358 --- /dev/null +++ b/zephyr/management/commands/reset_colors.py @@ -0,0 +1,21 @@ +from django.core.management.base import BaseCommand +from zephyr.models import StreamColor, UserProfile, Subscription, Recipient + +class Command(BaseCommand): + help = """Reset all colors for a person to the default grey""" + + def handle(self, *args, **options): + if not args: + self.print_help("python manage.py", "reset_colors") + exit(1) + + for email in args: + user_profile = UserProfile.objects.get(user__email__iexact=email) + subs = Subscription.objects.filter(user_profile=user_profile, + active=True, + recipient__type=Recipient.STREAM) + + for sub in subs: + stream_color, _ = StreamColor.objects.get_or_create(subscription=sub) + stream_color.color = StreamColor.DEFAULT_STREAM_COLOR + stream_color.save()