|
|
@ -4,7 +4,14 @@ from django.shortcuts import get_object_or_404 |
|
|
from utils.pagination import NoPagination |
|
|
from utils.pagination import NoPagination |
|
|
|
|
|
|
|
|
from ..models import HadisSect, HadisCategory |
|
|
from ..models import HadisSect, HadisCategory |
|
|
from ..serializers import HadisCategorySectListSerializer, HadisCategoryTreeSerializer, CategorySerializer , HadisCategorySelectSerializer , HadisCategorySelectSourceSerializer |
|
|
|
|
|
|
|
|
from ..serializers import ( |
|
|
|
|
|
HadisCategorySectListSerializer, |
|
|
|
|
|
HadisCategoryTreeSerializer, |
|
|
|
|
|
CategorySerializer , |
|
|
|
|
|
HadisCategorySelectSerializer , |
|
|
|
|
|
HadisCategorySelectSourceSerializer, |
|
|
|
|
|
get_localized_text |
|
|
|
|
|
) |
|
|
from ..docs import ( |
|
|
from ..docs import ( |
|
|
hadis_sect_list_swagger, |
|
|
hadis_sect_list_swagger, |
|
|
hadis_category_tree_swagger, |
|
|
hadis_category_tree_swagger, |
|
|
@ -103,7 +110,7 @@ class HadisCategoryTreeView(ListAPIView): |
|
|
grouped_data[sect_type]['sects'][sect_id] = { |
|
|
grouped_data[sect_type]['sects'][sect_id] = { |
|
|
'id': category.sect.id, |
|
|
'id': category.sect.id, |
|
|
'sect_type': category.sect.sect_type, |
|
|
'sect_type': category.sect.sect_type, |
|
|
'title': category.sect.title, |
|
|
|
|
|
|
|
|
'title': get_localized_text(category.sect.title,self.request), |
|
|
'description': category.sect.description, |
|
|
'description': category.sect.description, |
|
|
'order': category.sect.order |
|
|
'order': category.sect.order |
|
|
} |
|
|
} |
|
|
@ -135,14 +142,15 @@ class HadisCategoryTreeView(ListAPIView): |
|
|
|
|
|
|
|
|
def build_enhanced_category_tree(self, category, serializer_instance): |
|
|
def build_enhanced_category_tree(self, category, serializer_instance): |
|
|
"""Build enhanced category tree with father category info and hadis details""" |
|
|
"""Build enhanced category tree with father category info and hadis details""" |
|
|
base_data = serializer_instance.to_dict(category) |
|
|
|
|
|
|
|
|
|
|
|
# Enhance children with additional information |
|
|
|
|
|
|
|
|
# serializer_instance already has context={'request': request} |
|
|
|
|
|
base_data = serializer_instance.to_dict(category, request=self.request) |
|
|
|
|
|
|
|
|
|
|
|
# Rest of the code... |
|
|
enhanced_children = [] |
|
|
enhanced_children = [] |
|
|
for child_data in base_data.get('children', []): |
|
|
for child_data in base_data.get('children', []): |
|
|
enhanced_child = self.enhance_child_data(child_data, category, serializer_instance) |
|
|
enhanced_child = self.enhance_child_data(child_data, category, serializer_instance) |
|
|
enhanced_children.append(enhanced_child) |
|
|
enhanced_children.append(enhanced_child) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
base_data['children'] = enhanced_children |
|
|
base_data['children'] = enhanced_children |
|
|
return base_data |
|
|
return base_data |
|
|
|
|
|
|
|
|
@ -152,7 +160,7 @@ class HadisCategoryTreeView(ListAPIView): |
|
|
# Add father category information |
|
|
# Add father category information |
|
|
child_data['father_category'] = { |
|
|
child_data['father_category'] = { |
|
|
'id': parent_category.id, |
|
|
'id': parent_category.id, |
|
|
'name': parent_category.title, |
|
|
|
|
|
|
|
|
'title': get_localized_text(parent_category.title,self.request), |
|
|
'sect_id': parent_category.sect.id, |
|
|
'sect_id': parent_category.sect.id, |
|
|
'sect_type': parent_category.sect.sect_type, |
|
|
'sect_type': parent_category.sect.sect_type, |
|
|
'source_type': parent_category.source_type |
|
|
'source_type': parent_category.source_type |
|
|
|