Last active
August 29, 2015 14:07
-
-
Save dbgarf/10214ba5fb7e61688f4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.views.generic import View | |
import json | |
class userView(View): | |
def get(self, request, user_id): | |
response_content = json.dumps({'message': 'user not updated'}) | |
return http.HttpResponse(response_content, status=200, mimetype='application/json') | |
def post(self, request, user_id): | |
user = User.objects.get(id=user_id) | |
user_page = UserPage.objects.get(user=user) | |
# Set UserPage state | |
if state == "onboarding": | |
# Delete the onboarding fields and set the user_page | |
user.completed_onboarding = False | |
user.save() | |
user_page.current_page = 'onboarding' | |
elif state == "intro_video": | |
# Delete any IntroVideo objects and set the user_page | |
try: | |
introvideo_object = IntroVideo.objects.get(user=user) | |
introvideo_object.delete() | |
except: | |
pass | |
user_page.current_page = 'intro_video_page' | |
elif state == "quiz": | |
# Delete any Quiz objects and set page manager | |
try: | |
quiz_object = Quiz.objects.get(user=user) | |
quiz_object.delete() | |
except: | |
pass | |
user_page.current_page = 'quiz_page' | |
user_page.save() | |
response_content = json.dumps({'message': 'user successfully updated'}) | |
return http.HttpResponse(response_content, status=200, mimetype='application/json') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment