mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 07:52:19 +00:00
set_stream_color: Pass color to get_or_create.
(imported from commit 0d5f1fd227fd6dc337291d2d07ba24f96080e9e2)
This commit is contained in:
@@ -419,13 +419,15 @@ def get_subscription(stream_name, user_profile):
|
|||||||
recipient=recipient, active=True)
|
recipient=recipient, active=True)
|
||||||
|
|
||||||
def set_stream_color(user_profile, stream_name, color=None):
|
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.
|
# TODO: sanitize color.
|
||||||
if not color:
|
if not color:
|
||||||
color = pick_color(user_profile)
|
color = pick_color(user_profile)
|
||||||
stream_color.color = color
|
subscription = get_subscription(stream_name, user_profile)
|
||||||
stream_color.save(update_fields=["color"])
|
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
|
return color
|
||||||
|
|
||||||
def do_add_subscription(user_profile, stream, no_log=False):
|
def do_add_subscription(user_profile, stream, no_log=False):
|
||||||
|
|||||||
Reference in New Issue
Block a user