Added some logic
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
from django.shortcuts import render
|
||||
from rest_framework import viewsets
|
||||
|
||||
# Create your views here.
|
||||
from apps.shelf_items.models import ShelfItem
|
||||
from apps.shelf_items.serializers import ShelfItemSerializer
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework_simplejwt.authentication import JWTAuthentication
|
||||
|
||||
|
||||
class ShelfItemsViewSet(viewsets.ModelViewSet):
|
||||
queryset = ShelfItem.objects.all()
|
||||
serializer_class = ShelfItemSerializer
|
||||
|
||||
authentication_classes = [JWTAuthentication]
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get_queryset(self):
|
||||
return ShelfItem.objects.filter(
|
||||
shelf__user_id=self.request.user.pk,
|
||||
).select_related("book", "shelf").prefetch_related("book__authors")
|
||||
|
||||
Reference in New Issue
Block a user