mirror of https://github.com/zulip/zulip.git
do_make_stream_web_public: Update all affected fields.
Convert this function that absolutely makes a stream web public. We already have do_change_stream_invite_only to convert streams to public and private streams. We also update all the fields that should be set when a stream is made web public.
This commit is contained in:
parent
70c0abc2e5
commit
cba766f66f
|
@ -4569,9 +4569,11 @@ def do_change_stream_invite_only(
|
||||||
send_event(stream.realm, event, can_access_stream_user_ids(stream))
|
send_event(stream.realm, event, can_access_stream_user_ids(stream))
|
||||||
|
|
||||||
|
|
||||||
def do_change_stream_web_public(stream: Stream, is_web_public: bool) -> None:
|
def do_make_stream_web_public(stream: Stream) -> None:
|
||||||
stream.is_web_public = is_web_public
|
stream.is_web_public = True
|
||||||
stream.save(update_fields=["is_web_public"])
|
stream.invite_only = False
|
||||||
|
stream.history_public_to_subscribers = True
|
||||||
|
stream.save(update_fields=["invite_only", "history_public_to_subscribers", "is_web_public"])
|
||||||
|
|
||||||
|
|
||||||
def do_change_stream_post_policy(stream: Stream, stream_post_policy: int) -> None:
|
def do_change_stream_post_policy(stream: Stream, stream_post_policy: int) -> None:
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
from zerver.lib.actions import (
|
from zerver.lib.actions import (
|
||||||
do_change_stream_web_public,
|
|
||||||
do_deactivate_stream,
|
do_deactivate_stream,
|
||||||
|
do_make_stream_web_public,
|
||||||
get_web_public_streams,
|
get_web_public_streams,
|
||||||
get_web_public_subs,
|
get_web_public_subs,
|
||||||
)
|
)
|
||||||
|
@ -26,7 +26,7 @@ class GlobalPublicStreamTest(ZulipTestCase):
|
||||||
|
|
||||||
def test_non_existant_topic(self) -> None:
|
def test_non_existant_topic(self) -> None:
|
||||||
test_stream = self.make_stream("Test public archives")
|
test_stream = self.make_stream("Test public archives")
|
||||||
do_change_stream_web_public(test_stream, True)
|
do_make_stream_web_public(test_stream)
|
||||||
result = self.client_get(
|
result = self.client_get(
|
||||||
"/archive/streams/" + str(test_stream.id) + "/topics/nonexistenttopic",
|
"/archive/streams/" + str(test_stream.id) + "/topics/nonexistenttopic",
|
||||||
)
|
)
|
||||||
|
@ -34,7 +34,7 @@ class GlobalPublicStreamTest(ZulipTestCase):
|
||||||
|
|
||||||
def test_web_public_stream_topic(self) -> None:
|
def test_web_public_stream_topic(self) -> None:
|
||||||
test_stream = self.make_stream("Test public archives")
|
test_stream = self.make_stream("Test public archives")
|
||||||
do_change_stream_web_public(test_stream, True)
|
do_make_stream_web_public(test_stream)
|
||||||
|
|
||||||
def send_msg_and_get_result(msg: str) -> HttpResponse:
|
def send_msg_and_get_result(msg: str) -> HttpResponse:
|
||||||
self.send_stream_message(
|
self.send_stream_message(
|
||||||
|
@ -67,7 +67,7 @@ class GlobalPublicStreamTest(ZulipTestCase):
|
||||||
|
|
||||||
# Now add a second public stream
|
# Now add a second public stream
|
||||||
test_stream = self.make_stream("Test public archives")
|
test_stream = self.make_stream("Test public archives")
|
||||||
do_change_stream_web_public(test_stream, True)
|
do_make_stream_web_public(test_stream)
|
||||||
public_streams = get_web_public_streams(realm)
|
public_streams = get_web_public_streams(realm)
|
||||||
self.assert_length(public_streams, 2)
|
self.assert_length(public_streams, 2)
|
||||||
info = get_web_public_subs(realm)
|
info = get_web_public_subs(realm)
|
||||||
|
@ -111,7 +111,7 @@ class WebPublicTopicHistoryTest(ZulipTestCase):
|
||||||
|
|
||||||
def test_web_public_stream(self) -> None:
|
def test_web_public_stream(self) -> None:
|
||||||
test_stream = self.make_stream("Test public archives")
|
test_stream = self.make_stream("Test public archives")
|
||||||
do_change_stream_web_public(test_stream, True)
|
do_make_stream_web_public(test_stream)
|
||||||
|
|
||||||
self.send_stream_message(
|
self.send_stream_message(
|
||||||
self.example_user("iago"),
|
self.example_user("iago"),
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest import mock
|
||||||
import orjson
|
import orjson
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
from zerver.lib.actions import do_change_stream_invite_only, do_change_stream_web_public
|
from zerver.lib.actions import do_change_stream_invite_only, do_make_stream_web_public
|
||||||
from zerver.lib.cache import cache_get, to_dict_cache_key_id
|
from zerver.lib.cache import cache_get, to_dict_cache_key_id
|
||||||
from zerver.lib.emoji import emoji_name_to_emoji_code
|
from zerver.lib.emoji import emoji_name_to_emoji_code
|
||||||
from zerver.lib.message import extract_message_dict
|
from zerver.lib.message import extract_message_dict
|
||||||
|
@ -560,7 +560,7 @@ class ReactionEventTest(ZulipTestCase):
|
||||||
self.assert_json_success(remove)
|
self.assert_json_success(remove)
|
||||||
|
|
||||||
# Make stream web_public as well.
|
# Make stream web_public as well.
|
||||||
do_change_stream_web_public(stream, True)
|
do_make_stream_web_public(stream)
|
||||||
# For is_web_public streams, events even on old messages
|
# For is_web_public streams, events even on old messages
|
||||||
# should go to all subscribers, including guests like polonius.
|
# should go to all subscribers, including guests like polonius.
|
||||||
events = []
|
events = []
|
||||||
|
|
Loading…
Reference in New Issue