deactivate_stream_backend: Use access_stream_by_id.

This commit is contained in:
Tim Abbott 2017-01-29 16:52:48 -08:00
parent 826cc80c9e
commit 6685885741
2 changed files with 3 additions and 8 deletions

View File

@ -485,8 +485,7 @@ class StreamAdminTest(ZulipTestCase):
"privstream", subscribed=False, invite_only=True) "privstream", subscribed=False, invite_only=True)
result = self.client_delete('/json/streams/' + str(priv_stream.id)) result = self.client_delete('/json/streams/' + str(priv_stream.id))
self.assert_json_error( self.assert_json_error(result, "Invalid stream id")
result, "Cannot administer invite-only streams this way")
def attempt_unsubscribe_of_principal(self, is_admin=False, is_subbed=True, def attempt_unsubscribe_of_principal(self, is_admin=False, is_subbed=True,
invite_only=False, other_user_subbed=True): invite_only=False, other_user_subbed=True):

View File

@ -135,12 +135,8 @@ def principal_to_user_profile(agent, principal):
@require_realm_admin @require_realm_admin
def deactivate_stream_backend(request, user_profile, stream_id): def deactivate_stream_backend(request, user_profile, stream_id):
# type: (HttpRequest, UserProfile, int) -> HttpResponse # type: (HttpRequest, UserProfile, int) -> HttpResponse
target = get_and_validate_stream_by_id(stream_id, user_profile.realm) (stream, recipient, sub) = access_stream_by_id(user_profile, stream_id)
do_deactivate_stream(stream)
if target.invite_only and not subscribed_to_stream(user_profile, target):
return json_error(_('Cannot administer invite-only streams this way'))
do_deactivate_stream(target)
return json_success() return json_success()
@require_realm_admin @require_realm_admin