2016-06-02 21:43:41 +02:00
|
|
|
from django.http import HttpRequest, HttpResponse
|
2024-06-28 21:14:00 +02:00
|
|
|
from typing_extensions import Literal
|
2015-11-24 05:02:46 +01:00
|
|
|
|
2017-10-28 00:16:13 +02:00
|
|
|
from zerver.decorator import human_users_only
|
2017-10-04 21:37:37 +02:00
|
|
|
from zerver.lib.response import json_success
|
2024-06-28 21:14:00 +02:00
|
|
|
from zerver.lib.typed_endpoint import typed_endpoint
|
2015-11-24 05:02:46 +01:00
|
|
|
from zerver.models import UserProfile
|
|
|
|
|
2020-06-11 00:54:34 +02:00
|
|
|
|
2017-10-28 00:16:13 +02:00
|
|
|
@human_users_only
|
2024-06-28 21:14:00 +02:00
|
|
|
@typed_endpoint
|
2021-02-12 08:19:30 +01:00
|
|
|
def set_tutorial_status(
|
2024-06-28 21:14:00 +02:00
|
|
|
request: HttpRequest, user_profile: UserProfile, *, status: Literal["started", "finished"]
|
2021-02-12 08:19:30 +01:00
|
|
|
) -> HttpResponse:
|
2021-02-12 08:20:45 +01:00
|
|
|
if status == "started":
|
2015-11-24 05:02:46 +01:00
|
|
|
user_profile.tutorial_status = UserProfile.TUTORIAL_STARTED
|
2021-02-12 08:20:45 +01:00
|
|
|
elif status == "finished":
|
2015-11-24 05:02:46 +01:00
|
|
|
user_profile.tutorial_status = UserProfile.TUTORIAL_FINISHED
|
|
|
|
user_profile.save(update_fields=["tutorial_status"])
|
|
|
|
|
2022-01-31 13:44:02 +01:00
|
|
|
return json_success(request)
|