zulip/zerver/views/onboarding_steps.py

24 lines
936 B
Python
Raw Normal View History

from django.http import HttpRequest, HttpResponse
from django.utils.translation import gettext as _
from zerver.actions.onboarding_steps import do_mark_onboarding_step_as_read
from zerver.decorator import human_users_only
from zerver.lib.exceptions import JsonableError
from zerver.lib.onboarding_steps import ALL_ONBOARDING_STEPS
from zerver.lib.response import json_success
2024-06-06 14:12:39 +02:00
from zerver.lib.typed_endpoint import typed_endpoint
from zerver.models import UserProfile
@human_users_only
2024-06-06 14:12:39 +02:00
@typed_endpoint
def mark_onboarding_step_as_read(
2024-06-06 14:12:39 +02:00
request: HttpRequest, user: UserProfile, *, onboarding_step: str
) -> HttpResponse:
if not any(step.name == onboarding_step for step in ALL_ONBOARDING_STEPS):
raise JsonableError(
_("Unknown onboarding_step: {onboarding_step}").format(onboarding_step=onboarding_step)
)
do_mark_onboarding_step_as_read(user, onboarding_step)
return json_success(request)