mirror of https://github.com/zulip/zulip.git
Add a management command to reset your stream colors to the default.
(imported from commit f6891ad40088bf34686a7d8a2d910a9a0f3be7c2)
This commit is contained in:
parent
ff745e46ae
commit
1ca2f6fa7f
|
@ -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()
|
Loading…
Reference in New Issue