User Tours are walkthroughs we are able to give in our frontends. This sets up the backend support for them by creating the model, setting up the initial backfill, adds in a signal handler to init the UserTour model on User creation, and sets up some endpoints to get user tour information and update it. It is also being initialized with a waffle flag to control the rollout. The flag is intended to control all tours and not allow for opting into only some tours.
28 lines
969 B
Python
28 lines
969 B
Python
""" Models for the User Tour Experience. """
|
|
|
|
from django.contrib.auth import get_user_model
|
|
from django.db import models
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
class UserTour(models.Model):
|
|
"""
|
|
Model to track which tours a user needs to be shown.
|
|
|
|
Note: This does not track which tours a user has seen, only the ones they should.
|
|
|
|
.. no_pii:
|
|
"""
|
|
class CourseHomeChoices(models.TextChoices):
|
|
EXISTING_USER_TOUR = 'show-existing-user-tour', _('Show existing user tour')
|
|
NEW_USER_TOUR = 'show-new-user-tour', _('Show new user tour')
|
|
NO_TOUR = 'no-tour', _('Do not show user tour')
|
|
|
|
course_home_tour_status = models.CharField(
|
|
max_length=50, choices=CourseHomeChoices.choices, default=CourseHomeChoices.NEW_USER_TOUR
|
|
)
|
|
show_courseware_tour = models.BooleanField(default=True)
|
|
user = models.OneToOneField(User, related_name='tour', on_delete=models.CASCADE)
|