Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
onboarding: Mention demo orgs in Welcome Bot's PMs.
Eeshan Gargbf9c35ded427
diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.pyindex 53933f92ced..401618e3486 100644--- a/zerver/lib/onboarding.py+++ b/zerver/lib/onboarding.py@@ -70,31 +70,38 @@ def send_initial_pms(user: UserProfile) -> None:+ "\n").format(help_url=help_url)- content = (- _("Hello, and welcome to Zulip!") + "\n"- "\n"- + _("This is a private message from me, Welcome Bot.")- + " "- + _("Here are some tips to get you started:")- + "\n"- "* " + _("Download our [Desktop and mobile apps]({apps_url})") + "\n"- "* "- + _("Customize your account and notifications on your [Settings page]({settings_url})")- + "\n"- "* " + _("Type `?` to check out Zulip's keyboard shortcuts") + "\n"- "{organization_setup_text}"- "\n" + _("The most important shortcut is `r` to reply.") + "\n"- "\n"- + _("Practice sending a few messages by replying to this conversation.")- + " "- + _(- "If you're not into keyboards, that's okay too; "- "clicking anywhere on this message will also do the trick!"+ welcome_msg = _("Hello, and welcome to Zulip!")+ if user.realm.demo_organization_scheduled_deletion_date is not None:+ welcome_msg += " " + _(+ "Note that this is a [demo organization]({demo_org_help_url}) and will be automatically deleted in 30 days.")++ content = "".join(+ [+ welcome_msg + "\n\n",+ _("This is a private message from me, Welcome Bot.") + " ",+ _("Here are some tips to get you started:") + "\n",+ "* " + _("Download our [Desktop and mobile apps]({apps_url})") + "\n",+ "* "+ + _("Customize your account and notifications on your [Settings page]({settings_url})")+ + "\n",+ "* "+ + _("Type `?` to check out Zulip's keyboard shortcuts")+ + "\n {organization_setup_text}\n",+ _("The most important shortcut is `r` to reply.") + "\n\n",+ _("Practice sending a few messages by replying to this conversation.") + " ",+ _(+ "If you're not into keyboards, that's okay too; "+ "clicking anywhere on this message will also do the trick!"+ ),+ ])content = content.format(- apps_url="/apps", settings_url="#settings", organization_setup_text=organization_setup_text+ apps_url="/apps",+ settings_url="#settings",+ organization_setup_text=organization_setup_text,+ demo_org_help_url="/help/demo-organizations",)internal_send_private_message(diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.pyindex a499aba9f8a..eb05fbfe0b3 100644--- a/zerver/lib/test_classes.py+++ b/zerver/lib/test_classes.py@@ -628,6 +628,7 @@ Output:key: Optional[str] = None,realm_type: Optional[int] = Realm.ORG_TYPES["business"]["id"],enable_marketing_emails: Optional[bool] = True,+ is_demo_organization: Optional[bool] = False,**kwargs: Any,) -> HttpResponse:"""@@ -652,6 +653,7 @@ Output:"default_stream_group": default_stream_groups,"source_realm_id": source_realm_id,"enable_marketing_emails": enable_marketing_emails,+ "is_demo_organization": is_demo_organization,}if password is not None:payload["password"] = passworddiff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 1a208f4d4ac..06761132caa 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -1572,6 +1572,7 @@ class InviteUserTest(InviteUserBase):self.assertEqual(invitee_msg.sender.email, "[email protected]")self.assertTrue(invitee_msg.content.startswith("Hello, and welcome to Zulip!"))+ self.assertNotIn("demo organization", invitee_msg.content)def test_multi_user_invite(self) -> None:"""@@ -3158,6 +3159,77 @@ class RealmCreationTest(ZulipTestCase):self.assertEqual(user.realm, realm)self.assertFalse(user.enable_marketing_emails)+ @override_settings(OPEN_REALM_CREATION=True)+ def test_create_regular_realm_welcome_bot_pm(self) -> None:+ password = "test"+ string_id = "zuliptest"+ email = "[email protected]"+ realm_name = "Test"++ # Create new realm with the email+ result = self.client_post("/new/", {"email": email})+ self.assertEqual(result.status_code, 302)+ self.assertTrue(result["Location"].endswith(f"/accounts/new/send_confirm/{email}"))+ result = self.client_get(result["Location"])+ self.assert_in_response("Check your email so we can get started.", result)++ # Visit the confirmation link.+ confirmation_url = self.get_confirmation_url_from_outbox(email)+ result = self.client_get(confirmation_url)+ self.assertEqual(result.status_code, 200)++ result = self.submit_reg_form_for_user(+ email,+ password,+ realm_subdomain=string_id,+ realm_name=realm_name,+ enable_marketing_emails=False,+ )+ self.assertEqual(result.status_code, 302)++ # Make sure the correct Welcome Bot PM is sent+ welcome_msg = Message.objects.filter(+ sender__email="[email protected]", recipient__type=Recipient.PERSONAL+ ).latest("id")+ self.assertTrue(welcome_msg.content.startswith("Hello, and welcome to Zulip!"))+ self.assertNotIn("demo organization", welcome_msg.content)++ @override_settings(OPEN_REALM_CREATION=True)+ def test_create_demo_realm_welcome_bot_pm(self) -> None:+ password = "test"+ string_id = "zuliptest"+ email = "[email protected]"+ realm_name = "Test"++ # Create new realm with the email+ result = self.client_post("/new/", {"email": email})+ self.assertEqual(result.status_code, 302)+ self.assertTrue(result["Location"].endswith(f"/accounts/new/send_confirm/{email}"))+ result = self.client_get(result["Location"])+ self.assert_in_response("Check your email so we can get started.", result)++ # Visit the confirmation link.+ confirmation_url = self.get_confirmation_url_from_outbox(email)+ result = self.client_get(confirmation_url)+ self.assertEqual(result.status_code, 200)++ result = self.submit_reg_form_for_user(+ email,+ password,+ realm_subdomain=string_id,+ realm_name=realm_name,+ enable_marketing_emails=False,+ is_demo_organization=True,+ )+ self.assertEqual(result.status_code, 302)++ # Make sure the correct Welcome Bot PM is sent+ welcome_msg = Message.objects.filter(+ sender__email="[email protected]", recipient__type=Recipient.PERSONAL+ ).latest("id")+ self.assertTrue(welcome_msg.content.startswith("Hello, and welcome to Zulip!"))+ self.assertIn("demo organization", welcome_msg.content)+@override_settings(OPEN_REALM_CREATION=True, FREE_TRIAL_DAYS=30)def test_create_realm_during_free_trial(self) -> None:password = "test"