nu met een hoeveelheid meer profile
This commit is contained in:
@@ -4,3 +4,4 @@ from .api.track import *
|
||||
from .api.artist import *
|
||||
from .api.user import *
|
||||
from .api.album import *
|
||||
from .api.profile import *
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
from pickle import BUILD
|
||||
from playlist import serializers
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.authentication import SessionAuthentication
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from playlist.serializers import ProfileSerializer, BackgroundSerializer
|
||||
from playlist.models import Profile, Background
|
||||
|
||||
class ProfileDetailView(APIView):
|
||||
authentication_classes = [SessionAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request, id):
|
||||
profile = Profile.objects.get(pk=id)
|
||||
serializer = ProfileSerializer(profile)
|
||||
return Response(serializer.data)
|
||||
|
||||
class BackgroundListView(APIView):
|
||||
authentication_classes = [SessionAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request):
|
||||
backgrounds = Background.objects.all()
|
||||
serializer = BackgroundSerializer(backgrounds, many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
class BackgroundDetailView(APIView):
|
||||
authentication_classes = [SessionAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request, id):
|
||||
background = Background.objects.get(pk=id)
|
||||
serializer = BackgroundSerializer(background)
|
||||
return Response(serializer.data)
|
||||
@@ -10,7 +10,7 @@ class UserListView(APIView):
|
||||
permission_classes = [IsAuthenticated]
|
||||
def get(self, request):
|
||||
users = User.objects.all()
|
||||
serializer = UserSerializer(users, many=True)
|
||||
serializer = UserSerializer(users, many=True, context={'request': request})
|
||||
return Response(serializer.data)
|
||||
|
||||
class UserDetailView(APIView):
|
||||
@@ -18,5 +18,5 @@ class UserDetailView(APIView):
|
||||
permission_classes = [IsAuthenticated]
|
||||
def get(self, request, id):
|
||||
user = User.objects.get(pk=id)
|
||||
serializer = UserSerializer(user)
|
||||
serializer = UserSerializer(user, context={'request': request})
|
||||
return Response(serializer.data)
|
||||
|
||||
Reference in New Issue
Block a user