[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:
Tim Abbott
2013-03-29 15:57:02 -04:00
parent b06284717c
commit 0ee684a4b5
5 changed files with 22 additions and 1 deletions

View File

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