Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/user_profile/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
path("profile/<int:pk>/", views.UserProfileDetail.as_view(), name="profile-detail"),
path("profile/", views.UserProfileList.as_view(), name="profile-list"),
path("", views.UserList.as_view(), name="user-list"),
path("me/", views.MeView.as_view(), name="me"),
]
20 changes: 19 additions & 1 deletion server/user_profile/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.shortcuts import render

Check failure on line 1 in server/user_profile/views.py

View workflow job for this annotation

GitHub Actions / Run Flake8

'django.shortcuts.render' imported but unused
from rest_framework import generics, permissions
from rest_framework.response import Response
from rest_framework.views import APIView
Expand All @@ -10,11 +10,11 @@



# Create your views here.

Check failure on line 13 in server/user_profile/views.py

View workflow job for this annotation

GitHub Actions / Run Flake8

too many blank lines (4)


class UserList(APIView):

Check failure on line 16 in server/user_profile/views.py

View workflow job for this annotation

GitHub Actions / Run Flake8

expected 2 blank lines, found 4
permission_classes = (permissions.IsAuthenticated)
permission_classes = (permissions.IsAuthenticated,)

def get(self, request):
users = User.objects.all()
Expand All @@ -26,9 +26,27 @@
queryset = Profile.objects.all()
serializer_class = ProfileSerializer

class UserProfileDetail(generics.RetrieveUpdateAPIView):

Check failure on line 29 in server/user_profile/views.py

View workflow job for this annotation

GitHub Actions / Run Flake8

expected 2 blank lines, found 1
permission_classes = (permissions.IsAuthenticated, IsUserOrReadOnly)
queryset = Profile.objects.all()
serializer_class = ProfileSerializer

class MeView(APIView):
permission_classes = (permissions.IsAuthenticated,)

def get(self, request):
user = request.user
profile = Profile.objects.get(user=user)

return Response({
"id": user.id,
"username": user.username,
"email": user.email,
"first_name": user.first_name,
"last_name": user.last_name,
"phone_number": profile.phone_number,
"date_of_birth": profile.date_of_birth,
"address": profile.address,
})


Loading