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
|
2017-10-28 00:07:31 +02:00
|
|
|
from zerver.lib.request import has_request_variables, REQ
|
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.lib.validator import check_string
|
|
|
|
from zerver.models import UserProfile
|
|
|
|
|
2017-10-28 00:16:13 +02:00
|
|
|
@human_users_only
|
2015-11-24 05:02:46 +01:00
|
|
|
@has_request_variables
|
2017-12-06 10:23:13 +01:00
|
|
|
def set_tutorial_status(request: HttpRequest, user_profile: UserProfile,
|
|
|
|
status: str=REQ(validator=check_string)) -> HttpResponse:
|
2015-11-24 05:02:46 +01:00
|
|
|
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()
|