Default authentication on endpoints
Ik was er namelijk alweer eentje vergeten dus heh.
This commit is contained in:
@@ -2,33 +2,22 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user