Skip to content

Commit

Permalink
Merge pull request #1110 from uktrade/develop
Browse files Browse the repository at this point in the history
UAT/Production release
  • Loading branch information
Miriam Forner authored Jul 5, 2023
2 parents a6f21f1 + 5dcb264 commit 4b801fa
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# Generated by Django 4.1.9 on 2023-07-03 09:53

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
('wagtailmedia', '0004_duration_optional_floatfield'),
('wagtailimages', '0024_index_image_file_hash'),
('great_international', '0161_alter_internationalarticlelistingpage_tags_and_more'),
]

operations = [
migrations.AddField(
model_name='internationalarticlepage',
name='article_image_ar',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailimages.image',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_image_de',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailimages.image',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_image_en_gb',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailimages.image',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_image_es',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailimages.image',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_image_fr',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailimages.image',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_image_ja',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailimages.image',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_image_pt',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailimages.image',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_image_zh_hans',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailimages.image',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_video_ar',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailmedia.media',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_video_de',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailmedia.media',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_video_en_gb',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailmedia.media',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_video_es',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailmedia.media',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_video_fr',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailmedia.media',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_video_ja',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailmedia.media',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_video_pt',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailmedia.media',
),
),
migrations.AddField(
model_name='internationalarticlepage',
name='article_video_zh_hans',
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name='+',
to='wagtailmedia.media',
),
),
]
22 changes: 6 additions & 16 deletions great_international/panels/great_international.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ class BaseInternationalSectorPagePanels:


class InternationalArticlePagePanels:

content_panels = [
FieldPanel('title'),
FieldPanel('article_title'),
Expand All @@ -288,8 +287,10 @@ class InternationalArticlePagePanels:
children=[
FieldPanel('article_subheading'),
FieldPanel('article_teaser'),
FieldPanel('article_body_text')
]
FieldPanel('article_body_text'),
FieldPanel('article_image'),
MediaChooserPanel('article_video'),
],
),
MultiFieldPanel(
heading='CTA fields',
Expand All @@ -298,27 +299,16 @@ class InternationalArticlePagePanels:
FieldPanel('cta_teaser'),
FieldPanel('cta_link_label'),
FieldPanel('cta_link'),
]
],
),
SearchEngineOptimisationPanel(),
]

image_panels = [
FieldPanel('article_image'),
FieldPanel('article_video', widget=AdminMediaChooser),
]

settings_panels = [
FieldPanel('slug'),
FieldPanel('tags', widget=CheckboxSelectMultiple)
]
settings_panels = [FieldPanel('slug'), FieldPanel('tags', widget=CheckboxSelectMultiple)]

edit_handler = make_translated_interface(
content_panels=content_panels,
settings_panels=settings_panels,
other_panels=[
ObjectList(image_panels, heading='Images')
],
)


Expand Down
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
2 changes: 2 additions & 0 deletions great_international/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class InternationalArticlePageTranslationOptions(BaseTranslationOptions):
'type_of_article',
'article_teaser',
'article_body_text',
'article_video',
'article_image',
'cta_title',
'cta_teaser',
'cta_link_label',
Expand Down

0 comments on commit 4b801fa

Please sign in to comment.