updated authentication classes
This commit is contained in:
@@ -1,23 +1,15 @@
|
||||
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.models import Album
|
||||
from playlist.serializers import AlbumSerializer
|
||||
|
||||
class AlbumListView(APIView):
|
||||
authentication_classes = [SessionAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request):
|
||||
albums = Album.objects.all()
|
||||
serializer = AlbumSerializer(albums, many=True, context={'request': request})
|
||||
return Response(serializer.data)
|
||||
|
||||
class AlbumDetailView(APIView):
|
||||
authentication_classes = [SessionAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request, id):
|
||||
album = Album.objects.get(pk=id)
|
||||
serializer = AlbumSerializer(album, context={'request': request})
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
from django.db import IntegrityError
|
||||
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.models import Vote, Profile
|
||||
from playlist.serializers import VoteSerializer, VoteSaveSerializer
|
||||
|
||||
class VoteListView(APIView):
|
||||
authentication_classes = [SessionAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request, user_id = None):
|
||||
if user_id:
|
||||
votes = Vote.objects.filter(user_id=user_id)
|
||||
@@ -39,9 +34,6 @@ class VoteListView(APIView):
|
||||
return Response(status=403)
|
||||
|
||||
class VoteDetailView(APIView):
|
||||
authentication_classes = [SessionAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request, id):
|
||||
vote = Vote.objects.get(pk=id)
|
||||
serializer = VoteSerializer(vote, context={'request': request})
|
||||
|
||||
Reference in New Issue
Block a user