Skip to content

Commit 70d03e3

Browse files
committed
Update docstring for UserDetailsView and cleanup
1 parent 3737546 commit 70d03e3

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

rest_auth/registration/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ def validate(self, attrs):
6363
# http://stackoverflow.com/questions/8666316/facebook-oauth-2-0-code-and-token
6464

6565
# Case 1: We received the access_token
66-
if('access_token' in attrs):
66+
if 'access_token' in attrs:
6767
access_token = attrs.get('access_token')
6868

6969
# Case 2: We received the authorization code
70-
elif('code' in attrs):
70+
elif 'code' in attrs:
7171
self.callback_url = getattr(view, 'callback_url', None)
7272
self.client_class = getattr(view, 'client_class', None)
7373

rest_auth/views.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
from rest_framework import status
1010
from rest_framework.views import APIView
1111
from rest_framework.response import Response
12-
from rest_framework.generics import GenericAPIView
12+
from rest_framework.generics import GenericAPIView, RetrieveUpdateAPIView
1313
from rest_framework.permissions import IsAuthenticated, AllowAny
14-
from rest_framework.generics import RetrieveUpdateAPIView
1514

1615
if 'allauth' in settings.INSTALLED_APPS:
1716
from allauth.account import app_settings as allauth_settings
@@ -22,7 +21,6 @@
2221
PasswordChangeSerializer, JWTSerializer, create_token
2322
)
2423
from .models import TokenModel
25-
2624
from .utils import jwt_encode
2725

2826

@@ -123,13 +121,14 @@ def logout(self, request):
123121

124122
class UserDetailsView(RetrieveUpdateAPIView):
125123
"""
126-
Returns User's details in JSON format.
124+
Reads and updates UserModel fields
125+
Accepts GET, PUT, PATCH methods.
126+
127+
Default accepted fields: username, first_name, last_name
128+
Default display fields: pk, username, email, first_name, last_name
129+
Read-only fields: pk, email
127130
128-
Accepts the following GET parameters: token
129-
Accepts the following POST parameters:
130-
Required: token
131-
Optional: email, first_name, last_name and UserProfile fields
132-
Returns the updated UserProfile and/or User object.
131+
Returns UserModel fields.
133132
"""
134133
serializer_class = UserDetailsSerializer
135134
permission_classes = (IsAuthenticated,)

0 commit comments

Comments
 (0)