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.

hotspots: Extract INTRO_HOTSPOTS from ALL_HOTSPOTS.

Sumanth V Rao829f9272d2c4
diff --git a/zerver/lib/hotspots.py b/zerver/lib/hotspots.py
index cc5aa50c163..317b79ee412 100644
--- a/zerver/lib/hotspots.py
+++ b/zerver/lib/hotspots.py
@@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy
from zerver.models import UserHotspot, UserProfile
-ALL_HOTSPOTS: Dict[str, Dict[str, Promise]] = {
+INTRO_HOTSPOTS: Dict[str, Dict[str, Promise]] = {
"intro_reply": {
"title": ugettext_lazy("Reply to a message"),
"description": ugettext_lazy("Click anywhere on a message to reply."),
@@ -43,6 +43,13 @@ ALL_HOTSPOTS: Dict[str, Dict[str, Promise]] = {
},
}
+# We would most likely implement new hotspots in the future that aren't
+# a part of the initial tutorial. To that end, classifying them into
+# categories which are aggregated in ALL_HOTSPOTS, seems like a good start.
+ALL_HOTSPOTS: Dict[str, Dict[str, Promise]] = {
+ **INTRO_HOTSPOTS,
+}
+
def get_next_hotspots(user: UserProfile) -> List[Dict[str, object]]:
# For manual testing, it can be convenient to set
@@ -50,6 +57,9 @@ def get_next_hotspots(user: UserProfile) -> List[Dict[str, object]]:
# make it easy to click on all of the hotspots. Note that
# ALWAYS_SEND_ALL_HOTSPOTS has some bugs; see ReadTheDocs (link
# above) for details.
+ #
+ # Since this is just for development purposes, it's convinient for us to send
+ # all the hotspots rather than any specific category.
if settings.ALWAYS_SEND_ALL_HOTSPOTS:
return [
{
@@ -67,13 +77,13 @@ def get_next_hotspots(user: UserProfile) -> List[Dict[str, object]]:
seen_hotspots = frozenset(
UserHotspot.objects.filter(user=user).values_list("hotspot", flat=True)
)
- for hotspot in ["intro_reply", "intro_streams", "intro_topics", "intro_gear", "intro_compose"]:
+ for hotspot in INTRO_HOTSPOTS.keys():
if hotspot not in seen_hotspots:
return [
{
"name": hotspot,
- "title": str(ALL_HOTSPOTS[hotspot]["title"]),
- "description": str(ALL_HOTSPOTS[hotspot]["description"]),
+ "title": str(INTRO_HOTSPOTS[hotspot]["title"]),
+ "description": str(INTRO_HOTSPOTS[hotspot]["description"]),
"delay": 0.5,
}
]
diff --git a/zerver/tests/test_hotspots.py b/zerver/tests/test_hotspots.py
index f4213649728..8b0c4b83ebe 100644
--- a/zerver/tests/test_hotspots.py
+++ b/zerver/tests/test_hotspots.py
@@ -1,7 +1,7 @@
import orjson
from zerver.lib.actions import do_create_user, do_mark_hotspot_as_read
-from zerver.lib.hotspots import ALL_HOTSPOTS, get_next_hotspots
+from zerver.lib.hotspots import ALL_HOTSPOTS, INTRO_HOTSPOTS, get_next_hotspots
from zerver.lib.test_classes import ZulipTestCase
from zerver.models import UserHotspot, UserProfile, get_realm
@@ -27,9 +27,9 @@ class TestGetNextHotspots(ZulipTestCase):
self.assertEqual(len(hotspots), 1)
self.assertEqual(hotspots[0]["name"], "intro_streams")
- def test_all_done(self) -> None:
+ def test_all_intro_hotspots_done(self) -> None:
self.assertNotEqual(self.user.tutorial_status, UserProfile.TUTORIAL_FINISHED)
- for hotspot in ALL_HOTSPOTS:
+ for hotspot in INTRO_HOTSPOTS:
do_mark_hotspot_as_read(self.user, hotspot)
self.assertEqual(self.user.tutorial_status, UserProfile.TUTORIAL_FINISHED)
self.assertEqual(get_next_hotspots(self.user), [])