2016-06-02 21:43:41 +02:00
|
|
|
from django.http import HttpRequest, HttpResponse
|
2015-11-24 05:02:46 +01:00
|
|
|
|
2017-10-28 00:16:13 +02:00
|
|
|
from zerver.decorator import human_users_only
|
2020-06-11 00:54:34 +02:00
|
|
|
from zerver.lib.request import REQ, has_request_variables
|
2017-10-04 21:37:37 +02:00
|
|
|
from zerver.lib.response import json_success
|
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
|
2015-11-24 05:02:46 +01:00
|
|
|
@has_request_variables
|
2021-02-12 08:19:30 +01:00
|
|
|
def set_tutorial_status(
|
2021-05-04 16:59:17 +02:00
|
|
|
request: HttpRequest, user_profile: UserProfile, status: str = REQ()
|
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)
|