diff --git a/apps/hadis/docs.py b/apps/hadis/docs.py index 8cc822b..5b08db0 100644 --- a/apps/hadis/docs.py +++ b/apps/hadis/docs.py @@ -506,6 +506,41 @@ hadis_list_swagger = swagger_auto_schema( required=True, example='-330' ), + openapi.Parameter( + 'status', + openapi.IN_QUERY, + description="Filter by HadisStatus slug(s), comma-separated (e.g. 'sahih,hasan')", + type=openapi.TYPE_STRING, + required=False + ), + openapi.Parameter( + 'source', + openapi.IN_QUERY, + description="Filter by BookReference slug(s), comma-separated (e.g. 'al-kafi,sahih-al-bukhari')", + type=openapi.TYPE_STRING, + required=False + ), + openapi.Parameter( + 'author', + openapi.IN_QUERY, + description="Filter by BookAuthor slug(s) or ID(s), comma-separated", + type=openapi.TYPE_STRING, + required=False + ), + openapi.Parameter( + 'transmitter', + openapi.IN_QUERY, + description="Filter by Transmitter slug(s), comma-separated", + type=openapi.TYPE_STRING, + required=False + ), + openapi.Parameter( + 'search', + openapi.IN_QUERY, + description="Search query across text, title, narrator, and translations", + type=openapi.TYPE_STRING, + required=False + ), openapi.Parameter( 'is_bookmark', openapi.IN_QUERY, diff --git a/apps/hadis/views/hadis.py b/apps/hadis/views/hadis.py index e5b9cdc..664e77b 100644 --- a/apps/hadis/views/hadis.py +++ b/apps/hadis/views/hadis.py @@ -290,6 +290,16 @@ class HadisListView(ListAPIView): source_slugs = [s.strip() for s in source_filter.split(',')] queryset = queryset.filter(references__book_reference__slug__in=source_slugs) + # 👇 5. Apply Source Author Filter (Supports author or source_author, multiple comma-separated slugs/IDs) + author_filter = self.request.query_params.get('author', None) or self.request.query_params.get('source_author', None) + if author_filter: + author_slugs = [a.strip() for a in author_filter.split(',') if a.strip()] + author_q = Q(references__book_reference__author__slug__in=author_slugs) + numeric_ids = [int(a) for a in author_slugs if a.isdigit()] + if numeric_ids: + author_q |= Q(references__book_reference__author_id__in=numeric_ids) + queryset = queryset.filter(author_q) + # Filter by bookmarks if provided is_bookmark = self.request.query_params.get('is_bookmark', '').lower() if is_bookmark == 'true' and self.request.user.is_authenticated: