Added some logic

This commit is contained in:
maciejrusek
2026-03-18 19:14:26 +01:00
parent fdcd0653a6
commit 5722f0b7ea
13 changed files with 211 additions and 44 deletions

View File

@@ -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")