do_change_stream_description: Accept a stream as argument.

This commit is contained in:
Tim Abbott
2017-01-29 19:14:12 -08:00
parent 2dc90e8ebd
commit de3f539f58
3 changed files with 5 additions and 6 deletions

View File

@@ -2115,14 +2115,13 @@ def do_rename_stream(stream, new_name, log=True):
# email forwarding address to display the correctly-escaped new name. # email forwarding address to display the correctly-escaped new name.
return {"email_address": new_email} return {"email_address": new_email}
def do_change_stream_description(realm, stream_name, new_description): def do_change_stream_description(stream, new_description):
# type: (Realm, Text, Text) -> None # type: (Stream, Text) -> None
stream = get_stream(stream_name, realm)
stream.description = new_description stream.description = new_description
stream.save(update_fields=['description']) stream.save(update_fields=['description'])
event = dict(type='stream', op='update', event = dict(type='stream', op='update',
property='description', name=stream_name, property='description', name=stream.name,
value=new_description) value=new_description)
send_event(event, can_access_stream_user_ids(stream)) send_event(event, can_access_stream_user_ids(stream))

View File

@@ -1053,7 +1053,7 @@ class EventsRegisterTest(ZulipTestCase):
error = add_schema_checker('events[1]', events[1]) error = add_schema_checker('events[1]', events[1])
self.assert_on_error(error) self.assert_on_error(error)
action = lambda: do_change_stream_description(get_realm('zulip'), 'test_stream', u'new description') action = lambda: do_change_stream_description(stream, u'new description')
events = self.do_test(action) events = self.do_test(action)
error = stream_update_schema_checker('events[0]', events[0]) error = stream_update_schema_checker('events[0]', events[0])
self.assert_on_error(error) self.assert_on_error(error)

View File

@@ -93,7 +93,7 @@ def update_stream_backend(request, user_profile, stream_id,
(stream, recipient, sub) = access_stream_by_id(user_profile, stream_id) (stream, recipient, sub) = access_stream_by_id(user_profile, stream_id)
if description is not None: if description is not None:
do_change_stream_description(user_profile.realm, stream.name, description) do_change_stream_description(stream, description)
if new_name is not None: if new_name is not None:
new_name = new_name.strip() new_name = new_name.strip()
# Will raise if the new name has invalid characters. # Will raise if the new name has invalid characters.