Browse Source

hadiths statuses updated

master
Mohsen Taba 1 day ago
parent
commit
de9307d8d7
  1. 35
      apps/hadis/docs.py
  2. 10
      apps/hadis/views/hadis.py

35
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,

10
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:

Loading…
Cancel
Save