Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

onboarding_step: Don't show 'visibility_policy_banner' to new users.

Prakhar Pratyushfb5b72142184
diff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.py
index 0006098a650..ad1cac31ce4 100644
--- a/zerver/actions/create_user.py
+++ b/zerver/actions/create_user.py
@@ -42,6 +42,7 @@ from zerver.models import (
DefaultStreamGroup,
Message,
NamedUserGroup,
+ OnboardingStep,
PreregistrationRealm,
PreregistrationUser,
Realm,
@@ -229,6 +230,7 @@ def add_new_user_history(user_profile: UserProfile, streams: Iterable[Stream]) -
# * Fills in some recent historical messages
# * Notifies other users in realm and Zulip about the signup
# * Deactivates PreregistrationUser objects
+# * Mark 'visibility_policy_banner' as read
def process_new_human_user(
user_profile: UserProfile,
prereg_user: Optional[PreregistrationUser] = None,
@@ -305,6 +307,10 @@ def process_new_human_user(
send_initial_direct_message(user_profile)
+ # The 'visibility_policy_banner' is only displayed to existing users.
+ # Mark it as read for a new user.
+ OnboardingStep.objects.create(user=user_profile, onboarding_step="visibility_policy_banner")
+
def notify_created_user(user_profile: UserProfile, notify_user_ids: List[int]) -> None:
user_row = user_profile_to_user_row(user_profile)
diff --git a/zerver/tests/test_onboarding_steps.py b/zerver/tests/test_onboarding_steps.py
index e1cf50a0f18..f7bf07213a9 100644
--- a/zerver/tests/test_onboarding_steps.py
+++ b/zerver/tests/test_onboarding_steps.py
@@ -19,7 +19,10 @@ class TestGetNextOnboardingSteps(ZulipTestCase):
)
def test_some_done_some_not(self) -> None:
- do_mark_onboarding_step_as_read(self.user, "visibility_policy_banner")
+ # "visibility_policy_banner" is already marked as read for a new user.
+ onboarding_step = OnboardingStep.objects.get(user=self.user)
+ self.assertEqual(onboarding_step.onboarding_step, "visibility_policy_banner")
+
do_mark_onboarding_step_as_read(self.user, "intro_inbox_view_modal")
onboarding_steps = get_next_onboarding_steps(self.user)
self.assert_length(onboarding_steps, 3)
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py
index 9766a4dea41..592824e90c3 100644
--- a/zerver/tests/test_signup.py
+++ b/zerver/tests/test_signup.py
@@ -939,7 +939,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(90), self.assert_memcached_count(14):
+ with self.assert_database_query_count(91), self.assert_memcached_count(14):
with self.captureOnCommitCallbacks(execute=True):
self.register(self.nonreg_email("test"), "test")
diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py
index 715362acf65..3c7c42aa5e2 100644
--- a/zerver/tests/test_users.py
+++ b/zerver/tests/test_users.py
@@ -908,7 +908,7 @@ class QueryCountTest(ZulipTestCase):
prereg_user = PreregistrationUser.objects.get(email="[email protected]")
- with self.assert_database_query_count(80):
+ 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(