|
|
@ -166,13 +166,17 @@ class HadisCategorySelectSerializer(serializers.ModelSerializer): |
|
|
children_count = serializers.SerializerMethodField() |
|
|
children_count = serializers.SerializerMethodField() |
|
|
has_hadis = serializers.SerializerMethodField() |
|
|
has_hadis = serializers.SerializerMethodField() |
|
|
hadis_count= serializers.SerializerMethodField() |
|
|
hadis_count= serializers.SerializerMethodField() |
|
|
|
|
|
has_parent = serializers.SerializerMethodField() |
|
|
title = LocalizedField() |
|
|
title = LocalizedField() |
|
|
description =LocalizedField() |
|
|
description =LocalizedField() |
|
|
|
|
|
|
|
|
class Meta: |
|
|
class Meta: |
|
|
model = HadisCategory |
|
|
model = HadisCategory |
|
|
fields = ['id', 'title', 'source_type','slug', 'sect_id', |
|
|
fields = ['id', 'title', 'source_type','slug', 'sect_id', |
|
|
'sect_type','description','children_count','has_hadis','hadis_count', 'share_link', 'xmind_share_link'] |
|
|
|
|
|
|
|
|
'sect_type','description','children_count','has_hadis','hadis_count', 'has_parent', 'share_link', 'xmind_share_link'] |
|
|
|
|
|
|
|
|
|
|
|
def get_has_parent(self, obj): |
|
|
|
|
|
return obj.parent_id is not None |
|
|
|
|
|
|
|
|
def get_has_hadis(self, obj): |
|
|
def get_has_hadis(self, obj): |
|
|
"""Check if category can have hadis (no active children) and has hadis""" |
|
|
"""Check if category can have hadis (no active children) and has hadis""" |
|
|
@ -212,6 +216,7 @@ class HadisCategorySelectSourceSerializer(serializers.ModelSerializer): |
|
|
children_count = serializers.SerializerMethodField() |
|
|
children_count = serializers.SerializerMethodField() |
|
|
has_hadis = serializers.SerializerMethodField() |
|
|
has_hadis = serializers.SerializerMethodField() |
|
|
hadis_count = serializers.SerializerMethodField() |
|
|
hadis_count = serializers.SerializerMethodField() |
|
|
|
|
|
has_parent = serializers.SerializerMethodField() |
|
|
title = LocalizedField() |
|
|
title = LocalizedField() |
|
|
description = LocalizedField() |
|
|
description = LocalizedField() |
|
|
|
|
|
|
|
|
@ -219,7 +224,10 @@ class HadisCategorySelectSourceSerializer(serializers.ModelSerializer): |
|
|
class Meta: |
|
|
class Meta: |
|
|
model = HadisCategory |
|
|
model = HadisCategory |
|
|
fields = ['id', 'title', 'source_type','slug', 'sect_id', |
|
|
fields = ['id', 'title', 'source_type','slug', 'sect_id', |
|
|
'sect_type','description','children_count','has_hadis','hadis_count', 'share_link', 'xmind_share_link'] |
|
|
|
|
|
|
|
|
'sect_type','description','children_count','has_hadis','hadis_count', 'has_parent', 'share_link', 'xmind_share_link'] |
|
|
|
|
|
|
|
|
|
|
|
def get_has_parent(self, obj): |
|
|
|
|
|
return obj.parent_id is not None |
|
|
|
|
|
|
|
|
def get_has_hadis(self, obj): |
|
|
def get_has_hadis(self, obj): |
|
|
"""Check if category can have hadis (no active children) and has hadis""" |
|
|
"""Check if category can have hadis (no active children) and has hadis""" |
|
|
@ -253,6 +261,7 @@ class CategorySerializer(serializers.ModelSerializer): |
|
|
children_count = serializers.SerializerMethodField() |
|
|
children_count = serializers.SerializerMethodField() |
|
|
has_hadis =serializers.SerializerMethodField() |
|
|
has_hadis =serializers.SerializerMethodField() |
|
|
hadis_count=serializers.SerializerMethodField() |
|
|
hadis_count=serializers.SerializerMethodField() |
|
|
|
|
|
has_parent = serializers.SerializerMethodField() |
|
|
title = LocalizedField() |
|
|
title = LocalizedField() |
|
|
description = LocalizedField() |
|
|
description = LocalizedField() |
|
|
|
|
|
|
|
|
@ -261,7 +270,10 @@ class CategorySerializer(serializers.ModelSerializer): |
|
|
model = HadisCategory |
|
|
model = HadisCategory |
|
|
fields = ['id', 'title', 'sect_id', 'sect_type','source_type', |
|
|
fields = ['id', 'title', 'sect_id', 'sect_type','source_type', |
|
|
'description','slug', |
|
|
'description','slug', |
|
|
'children_count','has_hadis','hadis_count', 'share_link', 'xmind_share_link'] |
|
|
|
|
|
|
|
|
'children_count','has_hadis','hadis_count', 'has_parent', 'share_link', 'xmind_share_link'] |
|
|
|
|
|
|
|
|
|
|
|
def get_has_parent(self, obj): |
|
|
|
|
|
return obj.parent_id is not None |
|
|
|
|
|
|
|
|
def get_children_count(self, obj): |
|
|
def get_children_count(self, obj): |
|
|
# """Get count of active children categories that have children or hadis""" |
|
|
# """Get count of active children categories that have children or hadis""" |
|
|
|