set_stream_color: Pass color to get_or_create.

(imported from commit 0d5f1fd227fd6dc337291d2d07ba24f96080e9e2)
This commit is contained in:
Tim Abbott
2013-03-29 11:43:22 -04:00
parent 1c4ca370f2
commit 2a46c46fa8

View File

@@ -419,13 +419,15 @@ def get_subscription(stream_name, user_profile):
recipient=recipient, active=True)
def set_stream_color(user_profile, stream_name, color=None):
subscription = get_subscription(stream_name, user_profile)
stream_color, _ = StreamColor.objects.get_or_create(subscription=subscription[0])
# TODO: sanitize color.
if not color:
color = pick_color(user_profile)
stream_color.color = color
stream_color.save(update_fields=["color"])
subscription = get_subscription(stream_name, user_profile)
stream_color, created = StreamColor.objects.get_or_create(subscription=subscription[0],
defaults={'color': color})
if not created:
stream_color.color = color
stream_color.save(update_fields=["color"])
return color
def do_add_subscription(user_profile, stream, no_log=False):