mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 20:41:46 +00:00
[schema] [manual] Add colors to the subscription model.
This is preparatory for removing the StreamColor model, so we also set things up so anything changing the StreamColor model changes the Subscription model too. The manual task is to run the copy_colors.py management command after deployment to each of staging and prod. (imported from commit 1be7523ca59f5266eb2c4dc2009e31209ed49635)
This commit is contained in:
@@ -431,13 +431,16 @@ def set_stream_color_backend(user_profile, subscription, color=None):
|
||||
if not created:
|
||||
stream_color.color = color
|
||||
stream_color.save(update_fields=["color"])
|
||||
subscription.color = color
|
||||
subscription.save(update_fields=["color"])
|
||||
return color
|
||||
|
||||
def do_add_subscription(user_profile, stream, no_log=False):
|
||||
recipient = get_recipient(Recipient.STREAM, stream.id)
|
||||
color = pick_color(user_profile)
|
||||
(subscription, created) = Subscription.objects.get_or_create(
|
||||
user_profile=user_profile, recipient=recipient,
|
||||
defaults={'active': True})
|
||||
defaults={'active': True, 'color': color})
|
||||
did_subscribe = created
|
||||
if not subscription.active:
|
||||
did_subscribe = True
|
||||
|
||||
Reference in New Issue
Block a user