2017-01-24 01:48:35 +01:00
|
|
|
from zerver.models import UserProfile, UserHotspot
|
|
|
|
|
2017-04-15 05:50:59 +02:00
|
|
|
from typing import List, Text, Dict
|
|
|
|
|
2017-08-02 07:23:27 +02:00
|
|
|
SEND_ALL = False
|
|
|
|
|
2017-04-15 05:50:59 +02:00
|
|
|
ALL_HOTSPOTS = {
|
2017-07-14 03:20:27 +02:00
|
|
|
# TODO: Tag these for translation once we've finalized the content.
|
|
|
|
'click_to_reply': {
|
|
|
|
'title': 'Respond to a message',
|
|
|
|
'description': 'Click anywhere on a message to reply.',
|
|
|
|
},
|
|
|
|
'new_topic_button': {
|
|
|
|
'title': 'Start a new topic',
|
|
|
|
'description': 'Click the "New topic" button to start a new conversation.',
|
|
|
|
},
|
|
|
|
'stream_settings': {
|
|
|
|
'title': 'Stream settings',
|
|
|
|
'description': 'Most discussion on Zulip happens in streams. Click here to create or join additional streams.',
|
|
|
|
},
|
|
|
|
} # type Dict[str, Dict[str, Text]]
|
2017-01-24 01:48:35 +01:00
|
|
|
|
|
|
|
def get_next_hotspots(user):
|
2017-07-14 03:20:27 +02:00
|
|
|
# type: (UserProfile) -> List[Dict[str, object]]
|
2017-08-02 07:23:27 +02:00
|
|
|
|
|
|
|
if SEND_ALL:
|
|
|
|
result = []
|
|
|
|
for hotspot in ALL_HOTSPOTS:
|
|
|
|
result.append({
|
|
|
|
'name': hotspot,
|
|
|
|
'title': ALL_HOTSPOTS[hotspot]['title'],
|
|
|
|
'description': ALL_HOTSPOTS[hotspot]['description'],
|
|
|
|
'delay': 5,
|
|
|
|
})
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
2017-01-24 01:48:35 +01:00
|
|
|
seen_hotspots = frozenset(UserHotspot.objects.filter(user=user).values_list('hotspot', flat=True))
|
2017-07-14 03:20:27 +02:00
|
|
|
for hotspot in ['click_to_reply', 'new_topic_button', 'stream_settings']:
|
2017-01-24 01:48:35 +01:00
|
|
|
if hotspot not in seen_hotspots:
|
2017-07-14 03:20:27 +02:00
|
|
|
return [{
|
|
|
|
'name': hotspot,
|
|
|
|
'title': ALL_HOTSPOTS[hotspot]['title'],
|
|
|
|
'description': ALL_HOTSPOTS[hotspot]['description'],
|
|
|
|
'delay': 5,
|
|
|
|
}]
|
2017-01-24 01:48:35 +01:00
|
|
|
return []
|