|
|
|
@ -100,6 +100,24 @@ class AdminHadisCategoryViewSet(ReadOnlyModelViewSet): |
|
|
|
queryset = queryset.filter( |
|
|
|
Q(title__icontains=search) | Q(slug__icontains=search) |
|
|
|
) |
|
|
|
has_children = self.request.query_params.get("has_children") |
|
|
|
if has_children is not None and has_children != "all": |
|
|
|
if str(has_children).lower() in ["false", "0"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=False) |
|
|
|
elif str(has_children).lower() in ["true", "1"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=True) |
|
|
|
is_leaf = self.request.query_params.get("is_leaf") |
|
|
|
if is_leaf is not None and is_leaf != "all": |
|
|
|
if str(is_leaf).lower() in ["true", "1"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=False) |
|
|
|
elif str(is_leaf).lower() in ["false", "0"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=True) |
|
|
|
is_topic = self.request.query_params.get("is_topic") |
|
|
|
if is_topic is not None and is_topic != "all": |
|
|
|
if str(is_topic).lower() in ["true", "1"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=False) |
|
|
|
elif str(is_topic).lower() in ["false", "0"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=True) |
|
|
|
return queryset.order_by("order", "id") |
|
|
|
|
|
|
|
|
|
|
|
@ -164,12 +182,24 @@ class DovodiHadisCategoryViewSet(ModelViewSet): |
|
|
|
queryset = queryset.filter(annotated_has_hadith=False) |
|
|
|
elif str(has_hadith).lower() in ["true", "1"]: |
|
|
|
queryset = queryset.filter(annotated_has_hadith=True) |
|
|
|
has_children = self.request.query_params.get("has_children") |
|
|
|
if has_children is not None and has_children != "all": |
|
|
|
if str(has_children).lower() in ["false", "0"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=False) |
|
|
|
elif str(has_children).lower() in ["true", "1"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=True) |
|
|
|
is_leaf = self.request.query_params.get("is_leaf") |
|
|
|
if is_leaf is not None and is_leaf != "all": |
|
|
|
if str(is_leaf).lower() in ["true", "1"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=False) |
|
|
|
elif str(is_leaf).lower() in ["false", "0"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=True) |
|
|
|
is_topic = self.request.query_params.get("is_topic") |
|
|
|
if is_topic is not None and is_topic != "all": |
|
|
|
if str(is_topic).lower() in ["false", "0"]: |
|
|
|
queryset = queryset.filter(annotated_has_hadith=False) |
|
|
|
elif str(is_topic).lower() in ["true", "1"]: |
|
|
|
queryset = queryset.filter(annotated_has_hadith=True) |
|
|
|
if str(is_topic).lower() in ["true", "1"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=False) |
|
|
|
elif str(is_topic).lower() in ["false", "0"]: |
|
|
|
queryset = queryset.filter(annotated_has_children=True) |
|
|
|
return queryset.order_by("-id") |
|
|
|
|
|
|
|
|
|
|
|
|