|
|
|
@ -1206,10 +1206,12 @@ class HadisInterpretationDetailSerializer(serializers.ModelSerializer): |
|
|
|
translation = LocalizedField() |
|
|
|
references = DetailedInterpretationReferenceSerializer(many=True, read_only=True) |
|
|
|
category_info = serializers.SerializerMethodField() |
|
|
|
address = serializers.SerializerMethodField() |
|
|
|
images = serializers.SerializerMethodField() |
|
|
|
|
|
|
|
class Meta: |
|
|
|
model = HadisInterpretation |
|
|
|
fields = ['id', 'title', 'slug', 'narrator', 'text', 'translation', 'category_info', 'references','links'] |
|
|
|
fields = ['id', 'title', 'slug', 'narrator', 'text', 'translation', 'category_info', 'address', 'images', 'links', 'references'] |
|
|
|
|
|
|
|
def get_category_info(self, obj): |
|
|
|
return { |
|
|
|
@ -1218,6 +1220,24 @@ class HadisInterpretationDetailSerializer(serializers.ModelSerializer): |
|
|
|
"title": get_localized_text(obj.category.title, self.context.get('request')) |
|
|
|
} |
|
|
|
|
|
|
|
def get_address(self, obj): |
|
|
|
ref = obj.references.first() |
|
|
|
return ref.address if ref and ref.address else "" |
|
|
|
|
|
|
|
def get_images(self, obj): |
|
|
|
request = self.context.get('request') |
|
|
|
images_list = [] |
|
|
|
for ref in obj.references.all(): |
|
|
|
for img in ref.images.all(): |
|
|
|
if img.image: |
|
|
|
url = absolute_https_url(img.image.url, request) if request else absolute_https_url(img.image.url) |
|
|
|
images_list.append({ |
|
|
|
"id": img.id, |
|
|
|
"image": url, |
|
|
|
"thumbnail": url, |
|
|
|
}) |
|
|
|
return images_list |
|
|
|
|
|
|
|
|
|
|
|
class TransmitterOriginalTextDetailSerializer(serializers.ModelSerializer): |
|
|
|
title = LocalizedField() |
|
|
|
|