From 70d03e3e9be99e86967a568fee370dd24dab0f6d Mon Sep 17 00:00:00 2001 From: Maxim Kukhtenkov Date: Mon, 31 Oct 2016 15:01:06 -0700 Subject: [PATCH] Update docstring for UserDetailsView and cleanup --- rest_auth/registration/serializers.py | 4 ++-- rest_auth/views.py | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/rest_auth/registration/serializers.py b/rest_auth/registration/serializers.py index e3a5e33..d02297e 100644 --- a/rest_auth/registration/serializers.py +++ b/rest_auth/registration/serializers.py @@ -63,11 +63,11 @@ class SocialLoginSerializer(serializers.Serializer): # http://stackoverflow.com/questions/8666316/facebook-oauth-2-0-code-and-token # Case 1: We received the access_token - if('access_token' in attrs): + if 'access_token' in attrs: access_token = attrs.get('access_token') # Case 2: We received the authorization code - elif('code' in attrs): + elif 'code' in attrs: self.callback_url = getattr(view, 'callback_url', None) self.client_class = getattr(view, 'client_class', None) diff --git a/rest_auth/views.py b/rest_auth/views.py index 2f3b7d0..310ce0d 100644 --- a/rest_auth/views.py +++ b/rest_auth/views.py @@ -9,9 +9,8 @@ from django.utils.translation import ugettext_lazy as _ from rest_framework import status from rest_framework.views import APIView from rest_framework.response import Response -from rest_framework.generics import GenericAPIView +from rest_framework.generics import GenericAPIView, RetrieveUpdateAPIView from rest_framework.permissions import IsAuthenticated, AllowAny -from rest_framework.generics import RetrieveUpdateAPIView if 'allauth' in settings.INSTALLED_APPS: from allauth.account import app_settings as allauth_settings @@ -22,7 +21,6 @@ from .app_settings import ( PasswordChangeSerializer, JWTSerializer, create_token ) from .models import TokenModel - from .utils import jwt_encode @@ -123,13 +121,14 @@ class LogoutView(APIView): class UserDetailsView(RetrieveUpdateAPIView): """ - Returns User's details in JSON format. + Reads and updates UserModel fields + Accepts GET, PUT, PATCH methods. - Accepts the following GET parameters: token - Accepts the following POST parameters: - Required: token - Optional: email, first_name, last_name and UserProfile fields - Returns the updated UserProfile and/or User object. + Default accepted fields: username, first_name, last_name + Default display fields: pk, username, email, first_name, last_name + Read-only fields: pk, email + + Returns UserModel fields. """ serializer_class = UserDetailsSerializer permission_classes = (IsAuthenticated,)