do_make_stream_public: Accept a stream object, not a name.

This commit is contained in:
Tim Abbott 2017-01-29 18:42:41 -08:00
parent 54bcc675f7
commit 0a75480444
2 changed files with 3 additions and 12 deletions

View File

@ -2052,17 +2052,8 @@ def do_change_bot_type(user_profile, value):
user_profile.bot_type = value
user_profile.save(update_fields=["bot_type"])
def do_make_stream_public(user_profile, realm, stream_name):
# type: (UserProfile, Realm, Text) -> None
stream_name = stream_name.strip()
stream = get_stream(stream_name, realm)
if not stream:
raise JsonableError(_('Unknown stream "%s"') % (stream_name,))
if not subscribed_to_stream(user_profile, stream):
raise JsonableError(_('You are not invited to this stream.'))
def do_make_stream_public(realm, stream):
# type: (Realm, Stream) -> None
stream.invite_only = False
stream.save(update_fields=['invite_only'])

View File

@ -100,7 +100,7 @@ def update_stream_backend(request, user_profile, stream_id,
if is_private:
do_make_stream_private(user_profile.realm, stream.name)
else:
do_make_stream_public(user_profile, user_profile.realm, stream.name)
do_make_stream_public(user_profile.realm, stream)
return json_success()
def list_subscriptions_backend(request, user_profile):