Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Allow changing stream to be web-public based on creation setting.
Sahil Batraad99b4fac9a1
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.pyindex d8e4258c24f..c4b65adae50 100644--- a/zerver/tests/test_subs.py+++ b/zerver/tests/test_subs.py@@ -563,10 +563,23 @@ class StreamAdminTest(ZulipTestCase):result = self.client_patch(f"/json/streams/{stream_id}", params)self.assert_json_error(result, "Must be an organization or stream administrator")+ do_set_realm_property(+ realm, "create_web_public_stream_policy", Realm.POLICY_OWNERS_ONLY, acting_user=None+ )do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)result = self.client_patch(f"/json/streams/{stream_id}", params)- self.assert_json_error(result, "Must be an organization owner")+ self.assert_json_error(result, "Insufficient permission")++ do_set_realm_property(+ realm, "create_web_public_stream_policy", Realm.POLICY_NOBODY, acting_user=None+ )+ do_change_user_role(user_profile, UserProfile.ROLE_REALM_OWNER, acting_user=None)+ result = self.client_patch(f"/json/streams/{stream_id}", params)+ self.assert_json_error(result, "Insufficient permission")+ do_set_realm_property(+ realm, "create_web_public_stream_policy", Realm.POLICY_OWNERS_ONLY, acting_user=None+ )do_change_user_role(user_profile, UserProfile.ROLE_REALM_OWNER, acting_user=None)with self.settings(WEB_PUBLIC_STREAMS_ENABLED=False):result = self.client_patch(f"/json/streams/{stream_id}", params)diff --git a/zerver/views/streams.py b/zerver/views/streams.pyindex 569644b0e17..70218bd5830 100644--- a/zerver/views/streams.py+++ b/zerver/views/streams.py@@ -314,8 +314,8 @@ def update_stream_backend(# Enforce restrictions on creating web-public streams.if not user_profile.realm.web_public_streams_enabled():raise JsonableError(_("Web public streams are not enabled."))- if not user_profile.is_realm_owner:- raise OrganizationOwnerRequired()+ if not user_profile.can_create_web_public_streams():+ raise JsonableError(_("Insufficient permission"))# Forbid parameter combinations that are inconsistentif is_private or history_public_to_subscribers is False:raise JsonableError(_("Invalid parameters"))