Add a management command to reset your stream colors to the default.

(imported from commit f6891ad40088bf34686a7d8a2d910a9a0f3be7c2)
This commit is contained in:
Jessica McKellar 2013-03-18 15:46:31 -04:00
parent ff745e46ae
commit 1ca2f6fa7f
1 changed files with 21 additions and 0 deletions

View File

@ -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()