mirror of https://github.com/zulip/zulip.git
onboarding: Remove 'core team' private channel.
We no longer create the 'core team' private channel when a realm is created. Earlier, "New user announcements" channel was set to the "core team" channel. Now it is disabled by default. populate_db still creates the 'core team' channel to represent a private channel.
This commit is contained in:
parent
6baf981aa5
commit
61e606f656
|
@ -292,15 +292,6 @@ def do_create_realm(
|
|||
# stream is the new_stream_announcements_stream.
|
||||
DefaultStream.objects.create(stream=new_stream_announcements_stream, realm=realm)
|
||||
|
||||
signup_announcements_stream = ensure_stream(
|
||||
realm,
|
||||
Realm.INITIAL_PRIVATE_STREAM_NAME,
|
||||
invite_only=True,
|
||||
stream_description="A private stream for core team members.",
|
||||
acting_user=None,
|
||||
)
|
||||
realm.signup_announcements_stream = signup_announcements_stream
|
||||
|
||||
# New realm is initialized with the latest zulip update announcements
|
||||
# level as it shouldn't receive a bunch of old updates.
|
||||
realm.zulip_update_announcements_level = get_latest_zulip_update_announcements_level()
|
||||
|
@ -308,7 +299,6 @@ def do_create_realm(
|
|||
realm.save(
|
||||
update_fields=[
|
||||
"new_stream_announcements_stream",
|
||||
"signup_announcements_stream",
|
||||
"zulip_update_announcements_stream",
|
||||
"zulip_update_announcements_level",
|
||||
]
|
||||
|
|
|
@ -580,11 +580,6 @@ def do_create_user(
|
|||
)
|
||||
|
||||
if realm_creation:
|
||||
assert realm.signup_announcements_stream is not None
|
||||
bulk_add_subscriptions(
|
||||
realm, [realm.signup_announcements_stream], [user_profile], acting_user=None
|
||||
)
|
||||
|
||||
from zerver.lib.onboarding import send_initial_realm_messages
|
||||
|
||||
send_initial_realm_messages(realm)
|
||||
|
|
|
@ -268,21 +268,6 @@ def send_initial_realm_messages(realm: Realm) -> None:
|
|||
# Order corresponds to the ordering of the streams on the left sidebar, to make the initial Home
|
||||
# view slightly less overwhelming
|
||||
with override_language(realm.default_language):
|
||||
content_of_private_streams_topic_name = (
|
||||
_("This is a private channel, as indicated by the lock icon next to the channel name.")
|
||||
+ " "
|
||||
+ _("Private channels are only visible to channel members.")
|
||||
+ "\n"
|
||||
"\n"
|
||||
+ _(
|
||||
"To manage this channel, go to [Channel settings]({channel_settings_url}) "
|
||||
"and click on `{initial_private_channel_name}`."
|
||||
)
|
||||
).format(
|
||||
channel_settings_url="#channels/subscribed",
|
||||
initial_private_channel_name=Realm.INITIAL_PRIVATE_STREAM_NAME,
|
||||
)
|
||||
|
||||
content1_of_topic_demonstration_topic_name = (
|
||||
_(
|
||||
"This is a message on channel #**{default_notification_channel_name}** with the "
|
||||
|
@ -335,11 +320,6 @@ they can be disabled. [Learn more]({zulip_update_announcements_help_url}).
|
|||
)
|
||||
|
||||
welcome_messages: List[Dict[str, str]] = [
|
||||
{
|
||||
"stream": Realm.INITIAL_PRIVATE_STREAM_NAME,
|
||||
"topic_name": "private channels",
|
||||
"content": content_of_private_streams_topic_name,
|
||||
},
|
||||
{
|
||||
"stream": Realm.DEFAULT_NOTIFICATION_STREAM_NAME,
|
||||
"topic_name": "topic demonstration",
|
||||
|
|
|
@ -334,7 +334,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
|
|||
default_language = models.CharField(default="en", max_length=MAX_LANGUAGE_ID_LENGTH)
|
||||
|
||||
DEFAULT_NOTIFICATION_STREAM_NAME = "general"
|
||||
INITIAL_PRIVATE_STREAM_NAME = "core team"
|
||||
STREAM_EVENTS_NOTIFICATION_TOPIC_NAME = gettext_lazy("channel events")
|
||||
new_stream_announcements_stream = models.ForeignKey(
|
||||
"Stream",
|
||||
|
|
|
@ -161,7 +161,7 @@ def get_presence(client: Client) -> None:
|
|||
def add_default_stream(client: Client) -> None:
|
||||
# {code_example|start}
|
||||
# Add a stream to the set of default streams for new users.
|
||||
stream_id = 7
|
||||
stream_id = 4
|
||||
|
||||
result = client.add_default_stream(stream_id)
|
||||
# {code_example|end}
|
||||
|
@ -173,7 +173,7 @@ def add_default_stream(client: Client) -> None:
|
|||
def remove_default_stream(client: Client) -> None:
|
||||
# {code_example|start}
|
||||
# Remove a stream from the set of default streams for new users.
|
||||
request = {"stream_id": 7}
|
||||
request = {"stream_id": 4}
|
||||
|
||||
result = client.call_endpoint(
|
||||
url="/default_streams",
|
||||
|
@ -321,7 +321,7 @@ def send_invitations(client: Client) -> None:
|
|||
"invitee_emails": "example@zulip.com, logan@zulip.com",
|
||||
"invite_expires_in_minutes": 60 * 24 * 10, # 10 days
|
||||
"invite_as": 400,
|
||||
"stream_ids": [1, 8, 9],
|
||||
"stream_ids": [1, 5, 6],
|
||||
}
|
||||
result = client.call_endpoint(url="/invites", method="POST", request=request)
|
||||
# {code_example|end}
|
||||
|
@ -336,7 +336,7 @@ def create_reusable_invitation_link(client: Client) -> None:
|
|||
request = {
|
||||
"invite_expires_in_minutes": 60 * 24 * 10, # 10 days
|
||||
"invite_as": 400,
|
||||
"stream_ids": [1, 8, 9],
|
||||
"stream_ids": [1, 5, 6],
|
||||
}
|
||||
result = client.call_endpoint(url="/invites/multiuse", method="POST", request=request)
|
||||
# {code_example|end}
|
||||
|
@ -350,7 +350,7 @@ def revoke_email_invitation(client: Client) -> None:
|
|||
"invitee_emails": "delete-invite@zulip.com",
|
||||
"invite_expires_in_minutes": 14400, # 10 days
|
||||
"invite_as": 400,
|
||||
"stream_ids": [1, 8, 9],
|
||||
"stream_ids": [1, 5, 6],
|
||||
}
|
||||
result = client.call_endpoint(url="/invites", method="POST", request=request)
|
||||
|
||||
|
@ -915,7 +915,7 @@ def update_subscription_settings(client: Client) -> None:
|
|||
"value": True,
|
||||
},
|
||||
{
|
||||
"stream_id": 7,
|
||||
"stream_id": 4,
|
||||
"property": "color",
|
||||
"value": "#f00f00",
|
||||
},
|
||||
|
|
|
@ -5879,7 +5879,7 @@ paths:
|
|||
items:
|
||||
type: integer
|
||||
minLength: 1
|
||||
example: 8
|
||||
example: 5
|
||||
content:
|
||||
description: |
|
||||
The updated content of the scheduled message.
|
||||
|
@ -6022,7 +6022,7 @@ paths:
|
|||
description: |
|
||||
The ID of the target stream.
|
||||
type: integer
|
||||
example: 7
|
||||
example: 4
|
||||
required:
|
||||
- stream_id
|
||||
encoding:
|
||||
|
@ -6073,7 +6073,7 @@ paths:
|
|||
description: |
|
||||
The ID of the target stream.
|
||||
type: integer
|
||||
example: 7
|
||||
example: 4
|
||||
required:
|
||||
- stream_id
|
||||
encoding:
|
||||
|
@ -11977,7 +11977,7 @@ paths:
|
|||
type: array
|
||||
items:
|
||||
type: integer
|
||||
example: [1, 2]
|
||||
example: [1, 4]
|
||||
required:
|
||||
- invitee_emails
|
||||
- stream_ids
|
||||
|
@ -12115,7 +12115,7 @@ paths:
|
|||
items:
|
||||
type: integer
|
||||
default: []
|
||||
example: [1, 2]
|
||||
example: [1, 4]
|
||||
encoding:
|
||||
invite_expires_in_minutes:
|
||||
contentType: application/json
|
||||
|
|
|
@ -1155,7 +1155,7 @@ class FetchQueriesTest(ZulipTestCase):
|
|||
|
||||
self.login_user(user)
|
||||
|
||||
with self.assert_database_query_count(43):
|
||||
with self.assert_database_query_count(42):
|
||||
with mock.patch("zerver.lib.events.always_want") as want_mock:
|
||||
fetch_initial_state_data(user)
|
||||
|
||||
|
|
|
@ -1215,7 +1215,7 @@ class NormalActionsTest(BaseAction):
|
|||
)
|
||||
prereg_user = PreregistrationUser.objects.get(email="foo@zulip.com")
|
||||
|
||||
with self.verify_action(state_change_expected=True, num_events=7) as events:
|
||||
with self.verify_action(state_change_expected=True, num_events=6) as events:
|
||||
do_create_user(
|
||||
"foo@zulip.com",
|
||||
"password",
|
||||
|
@ -1225,7 +1225,7 @@ class NormalActionsTest(BaseAction):
|
|||
acting_user=None,
|
||||
)
|
||||
|
||||
check_invites_changed("events[6]", events[6])
|
||||
check_invites_changed("events[6]", events[5])
|
||||
|
||||
def test_typing_events(self) -> None:
|
||||
with self.verify_action(state_change_expected=False) as events:
|
||||
|
@ -1469,6 +1469,10 @@ class NormalActionsTest(BaseAction):
|
|||
)
|
||||
|
||||
def test_register_events(self) -> None:
|
||||
realm = self.user_profile.realm
|
||||
realm.signup_announcements_stream = get_stream("core team", realm)
|
||||
realm.save(update_fields=["signup_announcements_stream"])
|
||||
|
||||
with self.verify_action(num_events=5) as events:
|
||||
self.register("test1@zulip.com", "test1")
|
||||
self.assert_length(events, 5)
|
||||
|
@ -1496,6 +1500,9 @@ class NormalActionsTest(BaseAction):
|
|||
RealmUserDefault.EMAIL_ADDRESS_VISIBILITY_ADMINS,
|
||||
acting_user=None,
|
||||
)
|
||||
realm = self.user_profile.realm
|
||||
realm.signup_announcements_stream = get_stream("core team", realm)
|
||||
realm.save(update_fields=["signup_announcements_stream"])
|
||||
|
||||
with self.verify_action(num_events=5) as events:
|
||||
self.register("test1@zulip.com", "test1")
|
||||
|
|
|
@ -257,7 +257,7 @@ class HomeTest(ZulipTestCase):
|
|||
self.client_post("/json/bots", bot_info)
|
||||
|
||||
# Verify succeeds once logged-in
|
||||
with self.assert_database_query_count(53):
|
||||
with self.assert_database_query_count(52):
|
||||
with patch("zerver.lib.cache.cache_set") as cache_mock:
|
||||
result = self._get_home_page(stream="Denmark")
|
||||
self.check_rendered_logged_in_app(result)
|
||||
|
@ -562,7 +562,7 @@ class HomeTest(ZulipTestCase):
|
|||
def test_num_queries_for_realm_admin(self) -> None:
|
||||
# Verify number of queries for Realm admin isn't much higher than for normal users.
|
||||
self.login("iago")
|
||||
with self.assert_database_query_count(53):
|
||||
with self.assert_database_query_count(52):
|
||||
with patch("zerver.lib.cache.cache_set") as cache_mock:
|
||||
result = self._get_home_page()
|
||||
self.check_rendered_logged_in_app(result)
|
||||
|
@ -593,7 +593,7 @@ class HomeTest(ZulipTestCase):
|
|||
self._get_home_page()
|
||||
|
||||
# Then for the second page load, measure the number of queries.
|
||||
with self.assert_database_query_count(48):
|
||||
with self.assert_database_query_count(47):
|
||||
result = self._get_home_page()
|
||||
|
||||
# Do a sanity check that our new streams were in the payload.
|
||||
|
|
|
@ -918,6 +918,10 @@ class InviteUserTest(InviteUserBase):
|
|||
"""
|
||||
self.login("hamlet")
|
||||
user_profile = self.example_user("hamlet")
|
||||
realm = user_profile.realm
|
||||
realm.signup_announcements_stream = get_stream("core team", realm)
|
||||
realm.save(update_fields=["signup_announcements_stream"])
|
||||
|
||||
private_stream_name = "Secret"
|
||||
self.make_stream(private_stream_name, invite_only=True)
|
||||
self.subscribe(user_profile, private_stream_name)
|
||||
|
|
|
@ -14,9 +14,10 @@ from zerver.actions.user_settings import do_change_user_setting
|
|||
from zerver.lib.initial_password import initial_password
|
||||
from zerver.lib.test_classes import ZulipTestCase
|
||||
from zerver.lib.timezone import canonicalize_timezone
|
||||
from zerver.models import Message, Realm, Recipient, Stream, UserProfile
|
||||
from zerver.models import Message, Recipient, Stream, UserProfile
|
||||
from zerver.models.realms import get_realm
|
||||
from zerver.models.recipients import get_huddle_user_ids
|
||||
from zerver.models.streams import get_stream
|
||||
from zerver.models.users import get_system_bot
|
||||
from zerver.signals import JUST_CREATED_THRESHOLD, get_device_browser, get_device_os
|
||||
|
||||
|
@ -274,6 +275,8 @@ class TestNotifyNewUser(ZulipTestCase):
|
|||
|
||||
def test_notify_realm_of_new_user(self) -> None:
|
||||
realm = get_realm("zulip")
|
||||
realm.signup_announcements_stream = get_stream("core team", realm)
|
||||
realm.save(update_fields=["signup_announcements_stream"])
|
||||
new_user = self.example_user("cordelia")
|
||||
message_count = self.get_message_count()
|
||||
|
||||
|
@ -282,7 +285,7 @@ class TestNotifyNewUser(ZulipTestCase):
|
|||
message = self.get_last_message()
|
||||
self.assertEqual(message.recipient.type, Recipient.STREAM)
|
||||
actual_stream = Stream.objects.get(id=message.recipient.type_id)
|
||||
self.assertEqual(actual_stream.name, Realm.INITIAL_PRIVATE_STREAM_NAME)
|
||||
self.assertEqual(actual_stream.name, "core team")
|
||||
self.assertIn(
|
||||
f"@_**Cordelia, Lear's daughter|{new_user.id}** joined this organization.",
|
||||
message.content,
|
||||
|
@ -299,6 +302,8 @@ class TestNotifyNewUser(ZulipTestCase):
|
|||
admin_user_ids = set(realm.get_human_admin_users().values_list("id", flat=True))
|
||||
notification_bot = get_system_bot(settings.NOTIFICATION_BOT, realm.id)
|
||||
expected_group_direct_message_user_ids = admin_user_ids | {notification_bot.id}
|
||||
realm.signup_announcements_stream = get_stream("core team", realm)
|
||||
realm.save(update_fields=["signup_announcements_stream"])
|
||||
|
||||
user_count = get_latest_seat_count(realm)
|
||||
extra_licenses = 5
|
||||
|
|
|
@ -1157,9 +1157,7 @@ class RealmTest(ZulipTestCase):
|
|||
self.assertEqual(realm.new_stream_announcements_stream.name, "general")
|
||||
self.assertEqual(realm.new_stream_announcements_stream.realm, realm)
|
||||
|
||||
assert realm.signup_announcements_stream is not None
|
||||
self.assertEqual(realm.signup_announcements_stream.name, "core team")
|
||||
self.assertEqual(realm.signup_announcements_stream.realm, realm)
|
||||
self.assertIsNone(realm.signup_announcements_stream)
|
||||
|
||||
self.assertEqual(realm.plan_type, Realm.PLAN_TYPE_LIMITED)
|
||||
|
||||
|
@ -1205,9 +1203,7 @@ class RealmTest(ZulipTestCase):
|
|||
self.assertEqual(realm.new_stream_announcements_stream.name, "general")
|
||||
self.assertEqual(realm.new_stream_announcements_stream.realm, realm)
|
||||
|
||||
assert realm.signup_announcements_stream is not None
|
||||
self.assertEqual(realm.signup_announcements_stream.name, "core team")
|
||||
self.assertEqual(realm.signup_announcements_stream.realm, realm)
|
||||
self.assertIsNone(realm.signup_announcements_stream)
|
||||
|
||||
def test_realm_is_web_public(self) -> None:
|
||||
realm = get_realm("zulip")
|
||||
|
|
|
@ -932,7 +932,7 @@ class LoginTest(ZulipTestCase):
|
|||
# seem to be any O(N) behavior. Some of the cache hits are related
|
||||
# to sending messages, such as getting the welcome bot, looking up
|
||||
# the alert words for a realm, etc.
|
||||
with self.assert_database_query_count(104), self.assert_memcached_count(18):
|
||||
with self.assert_database_query_count(91), self.assert_memcached_count(14):
|
||||
with self.captureOnCommitCallbacks(execute=True):
|
||||
self.register(self.nonreg_email("test"), "test")
|
||||
|
||||
|
@ -1304,7 +1304,6 @@ class RealmCreationTest(ZulipTestCase):
|
|||
# Check welcome messages
|
||||
for stream_name, text, message_count in [
|
||||
(Realm.DEFAULT_NOTIFICATION_STREAM_NAME, "with the topic", 4),
|
||||
(Realm.INITIAL_PRIVATE_STREAM_NAME, "private channel", 1),
|
||||
]:
|
||||
stream = get_stream(stream_name, realm)
|
||||
recipient = stream.recipient
|
||||
|
@ -1741,11 +1740,9 @@ class RealmCreationTest(ZulipTestCase):
|
|||
# that are part of the stream -> channel rename, uncomment below.
|
||||
# # Check welcome messages
|
||||
# with_the_topic_in_italian = "con l'argomento"
|
||||
# private_stream_in_italian = "canale privato"
|
||||
|
||||
# for stream_name, text, message_count in [
|
||||
# (Realm.DEFAULT_NOTIFICATION_STREAM_NAME, with_the_topic_in_italian, 4),
|
||||
# (Realm.INITIAL_PRIVATE_STREAM_NAME, private_stream_in_italian, 1),
|
||||
# ]:
|
||||
# stream = get_stream(stream_name, realm)
|
||||
# recipient = stream.recipient
|
||||
|
|
|
@ -907,9 +907,9 @@ class QueryCountTest(ZulipTestCase):
|
|||
|
||||
prereg_user = PreregistrationUser.objects.get(email="fred@zulip.com")
|
||||
|
||||
with self.assert_database_query_count(93):
|
||||
with self.assert_memcached_count(23):
|
||||
with self.capture_send_event_calls(expected_num_events=11) as events:
|
||||
with self.assert_database_query_count(81):
|
||||
with self.assert_memcached_count(19):
|
||||
with self.capture_send_event_calls(expected_num_events=10) as events:
|
||||
fred = do_create_user(
|
||||
email="fred@zulip.com",
|
||||
password="password",
|
||||
|
|
|
@ -621,22 +621,24 @@ class Command(BaseCommand):
|
|||
# Add the realm internal bots to each realm.
|
||||
create_if_missing_realm_internal_bots()
|
||||
|
||||
# Create public streams.
|
||||
signups_stream = Realm.INITIAL_PRIVATE_STREAM_NAME
|
||||
|
||||
# Create streams.
|
||||
stream_list = [
|
||||
"Verona",
|
||||
"Denmark",
|
||||
"Scotland",
|
||||
"Venice",
|
||||
"Rome",
|
||||
signups_stream,
|
||||
"core team",
|
||||
]
|
||||
stream_dict: Dict[str, Dict[str, Any]] = {
|
||||
"Denmark": {"description": "A Scandinavian country"},
|
||||
"Scotland": {"description": "Located in the United Kingdom"},
|
||||
"Venice": {"description": "A northeastern Italian city"},
|
||||
"Rome": {"description": "Yet another Italian city", "is_web_public": True},
|
||||
"core team": {
|
||||
"description": "A private channel for core team members",
|
||||
"invite_only": True,
|
||||
},
|
||||
}
|
||||
|
||||
bulk_create_streams(zulip_realm, stream_dict)
|
||||
|
@ -660,12 +662,12 @@ class Command(BaseCommand):
|
|||
subscriptions_map = {
|
||||
"AARON@zulip.com": ["Verona"],
|
||||
"cordelia@zulip.com": ["Verona"],
|
||||
"hamlet@zulip.com": ["Verona", "Denmark", signups_stream],
|
||||
"hamlet@zulip.com": ["Verona", "Denmark", "core team"],
|
||||
"iago@zulip.com": [
|
||||
"Verona",
|
||||
"Denmark",
|
||||
"Scotland",
|
||||
signups_stream,
|
||||
"core team",
|
||||
],
|
||||
"othello@zulip.com": ["Verona", "Denmark", "Scotland"],
|
||||
"prospero@zulip.com": ["Verona", "Denmark", "Scotland", "Venice"],
|
||||
|
@ -675,7 +677,7 @@ class Command(BaseCommand):
|
|||
"Verona",
|
||||
"Denmark",
|
||||
"Venice",
|
||||
signups_stream,
|
||||
"core team",
|
||||
],
|
||||
"shiva@zulip.com": ["Verona", "Denmark", "Scotland"],
|
||||
}
|
||||
|
@ -937,10 +939,17 @@ class Command(BaseCommand):
|
|||
)
|
||||
|
||||
mit_user = get_user_by_delivery_email("sipbtest@mit.edu", mit_realm)
|
||||
mit_signup_stream = Stream.objects.get(
|
||||
name=Realm.INITIAL_PRIVATE_STREAM_NAME, realm=mit_realm
|
||||
bulk_create_streams(
|
||||
mit_realm,
|
||||
{
|
||||
"core team": {
|
||||
"description": "A private channel for core team members",
|
||||
"invite_only": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
bulk_add_subscriptions(mit_realm, [mit_signup_stream], [mit_user], acting_user=None)
|
||||
core_team_stream = Stream.objects.get(name="core team", realm=mit_realm)
|
||||
bulk_add_subscriptions(mit_realm, [core_team_stream], [mit_user], acting_user=None)
|
||||
|
||||
testsuite_lear_users = [
|
||||
("King Lear", "king@lear.org"),
|
||||
|
@ -951,11 +960,18 @@ class Command(BaseCommand):
|
|||
)
|
||||
|
||||
lear_user = get_user_by_delivery_email("king@lear.org", lear_realm)
|
||||
lear_signup_stream = Stream.objects.get(
|
||||
name=Realm.INITIAL_PRIVATE_STREAM_NAME, realm=lear_realm
|
||||
bulk_create_streams(
|
||||
lear_realm,
|
||||
{
|
||||
"core team": {
|
||||
"description": "A private channel for core team members",
|
||||
"invite_only": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
core_team_stream = Stream.objects.get(name="core team", realm=lear_realm)
|
||||
bulk_add_subscriptions(
|
||||
lear_realm, [lear_signup_stream], [lear_user], acting_user=None
|
||||
lear_realm, [core_team_stream], [lear_user], acting_user=None
|
||||
)
|
||||
|
||||
if not options["test_suite"]:
|
||||
|
|
Loading…
Reference in New Issue