def set_tutorial_status(request: HttpRequest, user_profile: UserProfile, status: str=REQ(validator=check_string)) -> HttpResponse: if status == 'started': user_profile.tutorial_status = UserProfile.TUTORIAL_STARTED elif status == 'finished': user_profile.tutorial_status = UserProfile.TUTORIAL_FINISHED user_profile.save(update_fields=["tutorial_status"]) return json_success()
def get_next_hotspots(user: UserProfile) -> List[Dict[str, object]]: # For manual testing, it can be convenient to set # ALWAYS_SEND_ALL_HOTSPOTS=True in `zproject/dev_settings.py` to # make it easy to click on all of the hotspots. if settings.ALWAYS_SEND_ALL_HOTSPOTS: return [{ 'name': hotspot, 'title': ALL_HOTSPOTS[hotspot]['title'], 'description': ALL_HOTSPOTS[hotspot]['description'], 'delay': 0, } for hotspot in ALL_HOTSPOTS] if user.tutorial_status == UserProfile.TUTORIAL_FINISHED: return [] seen_hotspots = frozenset( UserHotspot.objects.filter(user=user).values_list('hotspot', flat=True)) for hotspot in [ 'intro_reply', 'intro_streams', 'intro_topics', 'intro_compose' ]: if hotspot not in seen_hotspots: return [{ 'name': hotspot, 'title': ALL_HOTSPOTS[hotspot]['title'], 'description': ALL_HOTSPOTS[hotspot]['description'], 'delay': 0.5, }] user.tutorial_status = UserProfile.TUTORIAL_FINISHED user.save(update_fields=['tutorial_status']) return []
def get_next_hotspots(user: UserProfile) -> List[Dict[str, object]]: # Only used for manual testing SEND_ALL = False if settings.DEVELOPMENT and SEND_ALL: return [{ 'name': hotspot, 'title': ALL_HOTSPOTS[hotspot]['title'], 'description': ALL_HOTSPOTS[hotspot]['description'], 'delay': 0, } for hotspot in ALL_HOTSPOTS] if user.tutorial_status == UserProfile.TUTORIAL_FINISHED: return [] seen_hotspots = frozenset(UserHotspot.objects.filter(user=user).values_list('hotspot', flat=True)) for hotspot in ['intro_reply', 'intro_streams', 'intro_topics', 'intro_compose']: if hotspot not in seen_hotspots: return [{ 'name': hotspot, 'title': ALL_HOTSPOTS[hotspot]['title'], 'description': ALL_HOTSPOTS[hotspot]['description'], 'delay': 0.5, }] user.tutorial_status = UserProfile.TUTORIAL_FINISHED user.save(update_fields=['tutorial_status']) return []
def get_next_hotspots(user: UserProfile) -> List[Dict[str, object]]: # For manual testing, it can be convenient to set # ALWAYS_SEND_ALL_HOTSPOTS=True in `zproject/dev_settings.py` to # make it easy to click on all of the hotspots. if settings.ALWAYS_SEND_ALL_HOTSPOTS: return [{ 'name': hotspot, 'title': ALL_HOTSPOTS[hotspot]['title'], 'description': ALL_HOTSPOTS[hotspot]['description'], 'delay': 0, } for hotspot in ALL_HOTSPOTS] if user.tutorial_status == UserProfile.TUTORIAL_FINISHED: return [] seen_hotspots = frozenset(UserHotspot.objects.filter(user=user).values_list('hotspot', flat=True)) for hotspot in ['intro_reply', 'intro_streams', 'intro_topics', 'intro_compose']: if hotspot not in seen_hotspots: return [{ 'name': hotspot, 'title': ALL_HOTSPOTS[hotspot]['title'], 'description': ALL_HOTSPOTS[hotspot]['description'], 'delay': 0.5, }] user.tutorial_status = UserProfile.TUTORIAL_FINISHED user.save(update_fields=['tutorial_status']) return []
def get_next_hotspots(user: UserProfile) -> List[Dict[str, object]]: # For manual testing, it can be convenient to set # ALWAYS_SEND_ALL_HOTSPOTS=True in `zproject/dev_settings.py` to # 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. if settings.ALWAYS_SEND_ALL_HOTSPOTS: return [{ "name": hotspot, "title": str(ALL_HOTSPOTS[hotspot]["title"]), "description": str(ALL_HOTSPOTS[hotspot]["description"]), "delay": 0, } for hotspot in ALL_HOTSPOTS] if user.tutorial_status == UserProfile.TUTORIAL_FINISHED: return [] 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" ]: if hotspot not in seen_hotspots: return [{ "name": hotspot, "title": str(ALL_HOTSPOTS[hotspot]["title"]), "description": str(ALL_HOTSPOTS[hotspot]["description"]), "delay": 0.5, }] user.tutorial_status = UserProfile.TUTORIAL_FINISHED user.save(update_fields=["tutorial_status"]) return []
def get_next_hotspots(user: UserProfile) -> List[Dict[str, object]]: # For manual testing, it can be convenient to set # ALWAYS_SEND_ALL_HOTSPOTS=True in `zproject/dev_settings.py` to # 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 [{ "name": hotspot, "title": str(ALL_HOTSPOTS[hotspot]["title"]), "description": str(ALL_HOTSPOTS[hotspot]["description"]), "delay": 0, } for hotspot in ALL_HOTSPOTS] if user.tutorial_status == UserProfile.TUTORIAL_FINISHED: return [] seen_hotspots = frozenset( UserHotspot.objects.filter(user=user).values_list("hotspot", flat=True)) for hotspot in INTRO_HOTSPOTS.keys(): if hotspot not in seen_hotspots: return [{ "name": hotspot, "title": str(INTRO_HOTSPOTS[hotspot]["title"]), "description": str(INTRO_HOTSPOTS[hotspot]["description"]), "delay": 0.5, }] user.tutorial_status = UserProfile.TUTORIAL_FINISHED user.save(update_fields=["tutorial_status"]) return []
def copy_hotpots(source_profile: UserProfile, target_profile: UserProfile) -> None: for userhotspot in frozenset(UserHotspot.objects.filter(user=source_profile)): UserHotspot.objects.create(user=target_profile, hotspot=userhotspot.hotspot, timestamp=userhotspot.timestamp) target_profile.tutorial_status = source_profile.tutorial_status target_profile.onboarding_steps = source_profile.onboarding_steps target_profile.save(update_fields=['tutorial_status', 'onboarding_steps'])