Skip to content

Commit

Permalink
Update serializer class for article video
Browse files Browse the repository at this point in the history
  • Loading branch information
mforner13 committed Jul 4, 2023
1 parent 0ae32df commit 899b7c5
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions great_international/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@
)


class GreatMediaSerializer(serializers.Serializer):
title = serializers.CharField()
transcript = serializers.SerializerMethodField()
sources = serializers.SerializerMethodField()
url = serializers.CharField()
thumbnail = serializers.SerializerMethodField()
subtitles = serializers.SerializerMethodField()

def get_transcript(self, obj):
return obj.greatmedia.transcript

def get_sources(self, obj):
return obj.greatmedia.sources

def get_subtitles(self, obj):
return obj.greatmedia.subtitles

def get_thumbnail(self, obj):
if obj.thumbnail:
return obj.thumbnail.url


class EntitySummarySerializerBase(serializers.Serializer):
"""Base class for nested entities that don't need full page representations"""

Expand Down Expand Up @@ -301,7 +323,7 @@ class InternationalArticlePageSerializer(BasePageSerializer):

article_image = wagtail_fields.ImageRenditionField('original')
article_image_thumbnail = wagtail_fields.ImageRenditionField('fill-640x360', source='article_image')
article_video = core_fields.VideoField()
article_video = GreatMediaSerializer()

article_body_text = core_fields.MarkdownToHTMLField()

Expand Down Expand Up @@ -329,28 +351,6 @@ def get_freeport_data(self, instance):
return serializer.data


class GreatMediaSerializer(serializers.Serializer):
title = serializers.CharField()
transcript = serializers.SerializerMethodField()
sources = serializers.SerializerMethodField()
url = serializers.CharField()
thumbnail = serializers.SerializerMethodField()
subtitles = serializers.SerializerMethodField()

def get_transcript(self, obj):
return obj.greatmedia.transcript

def get_sources(self, obj):
return obj.greatmedia.sources

def get_subtitles(self, obj):
return obj.greatmedia.subtitles

def get_thumbnail(self, obj):
if obj.thumbnail:
return obj.thumbnail.url


class InternationalHomePageSerializer(BasePageSerializer):
# Note that this is massively cut down from the original version,
# but that the older fields still exist on the model (see the comment there)
Expand Down

0 comments on commit 899b7c5

Please sign in to comment.