This commit is contained in:
parent
0b92db278b
commit
91cd5c57b3
15 changed files with 251 additions and 17 deletions
0
backend/toolshed/api/__init__.py
Normal file
0
backend/toolshed/api/__init__.py
Normal file
24
backend/toolshed/api/friend.py
Normal file
24
backend/toolshed/api/friend.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from django.urls import path
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.viewsets import ViewSetMixin
|
||||
|
||||
from authentication.signature_auth import SignatureAuthentication
|
||||
from toolshed.serializers import FriendSerializer
|
||||
|
||||
|
||||
class Friends(APIView, ViewSetMixin):
|
||||
authentication_classes = [SignatureAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request, format=None): # /api/friends/ #
|
||||
user = request.user
|
||||
friends = user.friends.all()
|
||||
serializer = FriendSerializer(friends, many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('friends/', Friends.as_view(), name='friends'),
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue