rename_stream: Move stream already has name check to view.

This commit is contained in:
Tim Abbott 2017-01-29 19:03:32 -08:00
parent d059a0a90a
commit ccdf17f47e
2 changed files with 3 additions and 2 deletions

View File

@ -2067,7 +2067,7 @@ def do_rename_stream(realm, old_name, new_name, log=True):
if not stream: if not stream:
raise JsonableError(_('Unknown stream "%s"') % (old_name,)) raise JsonableError(_('Unknown stream "%s"') % (old_name,))
if get_stream(new_name, realm) and old_name.lower() != new_name.lower(): if get_stream(new_name, realm) is not None:
raise JsonableError(_('Stream name "%s" is already taken') % (new_name,)) raise JsonableError(_('Stream name "%s" is already taken') % (new_name,))
old_name = stream.name old_name = stream.name

View File

@ -98,7 +98,8 @@ def update_stream_backend(request, user_profile, stream_id,
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.
check_stream_name(new_name) check_stream_name(new_name)
if stream.name.lower() == new_name.lower():
return json_error(_("Stream already has that name!"))
do_rename_stream(user_profile.realm, stream.name, new_name) do_rename_stream(user_profile.realm, stream.name, new_name)
if is_private is not None: if is_private is not None:
do_change_stream_invite_only(stream, is_private) do_change_stream_invite_only(stream, is_private)