|
|
|
@ -134,6 +134,7 @@ class BookReferenceV2ListView(generics.ListAPIView): |
|
|
|
openapi.Parameter('sect', openapi.IN_QUERY, description="Filter by Sect/Type ID", type=openapi.TYPE_INTEGER), |
|
|
|
openapi.Parameter('pdf_available', openapi.IN_QUERY, description="Filter by PDF availability ('true' or 'false')", type=openapi.TYPE_STRING), |
|
|
|
openapi.Parameter('century', openapi.IN_QUERY, description="Filter by Century (e.g. '1', '2', 'before_islam')", type=openapi.TYPE_STRING), |
|
|
|
openapi.Parameter('search', openapi.IN_QUERY, description="Search term for book title, description, or author name", type=openapi.TYPE_STRING), |
|
|
|
] |
|
|
|
) |
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
@ -142,6 +143,15 @@ class BookReferenceV2ListView(generics.ListAPIView): |
|
|
|
def get_queryset(self): |
|
|
|
qs = BookReference.objects.prefetch_related('authors', 'tags', 'volumes').distinct().order_by('-created_at') |
|
|
|
|
|
|
|
search = self.request.query_params.get('search') |
|
|
|
if search: |
|
|
|
from django.db.models import Q |
|
|
|
qs = qs.filter( |
|
|
|
Q(title__icontains=search) | |
|
|
|
Q(description__icontains=search) | |
|
|
|
Q(authors__name__icontains=search) |
|
|
|
) |
|
|
|
|
|
|
|
category = self.request.query_params.get('category') |
|
|
|
if category: |
|
|
|
qs = qs.filter(subject_area__id=category) |
|
|
|
|