From 2bc81ff869290f9421ea02ec1231b15cca59b459 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Tue, 6 Aug 2019 14:27:36 +0100 Subject: [PATCH 01/22] Created capital invest contact form page --- core/serializer_mapping.py | 1 + .../0064_capitalinvestcontactformpage.py | 67 +++++++++++++++++++ great_international/models/capital_invest.py | 18 +++++ .../models/great_international.py | 1 + great_international/panels/capital_invest.py | 19 ++++++ great_international/serializers.py | 7 ++ great_international/translation.py | 24 +++++-- tests/great_international/test_models.py | 2 + 8 files changed, 133 insertions(+), 6 deletions(-) create mode 100644 great_international/migrations/0064_capitalinvestcontactformpage.py diff --git a/core/serializer_mapping.py b/core/serializer_mapping.py index ec495443..eeda3032 100644 --- a/core/serializer_mapping.py +++ b/core/serializer_mapping.py @@ -59,6 +59,7 @@ great_international.models.capital_invest.CapitalInvestRegionPage: great_international.serializers.CapitalInvestRegionPageSerializer, # NOQA great_international.models.capital_invest.CapitalInvestOpportunityListingPage: great_international.serializers.CapitalInvestOpportunityListingSerializer, # NOQA great_international.models.capital_invest.CapitalInvestOpportunityPage: great_international.serializers.CapitalInvestOpportunityPageSerializer, # NOQA + great_international.models.capital_invest.CapitalInvestContactFormPage: great_international.serializers.CapitalInvestContactFormPageSerializer, # NOQA great_international.models.invest.InvestInternationalHomePage: great_international.serializers.InvestInternationalHomePageSerializer, # NOQA great_international.models.invest.InvestHighPotentialOpportunityFormSuccessPage: great_international.serializers.InvestHighPotentialOpportunityFormSuccessPageSerializer, # NOQA great_international.models.invest.InvestHighPotentialOpportunityFormPage: great_international.serializers.InvestHighPotentialOpportunityFormPageSerializer, # NOQA diff --git a/great_international/migrations/0064_capitalinvestcontactformpage.py b/great_international/migrations/0064_capitalinvestcontactformpage.py new file mode 100644 index 00000000..ca246e20 --- /dev/null +++ b/great_international/migrations/0064_capitalinvestcontactformpage.py @@ -0,0 +1,67 @@ +# Generated by Django 2.2.3 on 2019-08-07 08:07 + +import core.model_fields +import core.models +import core.validators +from django.db import migrations, models +import django.db.models.deletion +import great_international.panels.capital_invest + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0041_group_collection_permissions_verbose_name_plural'), + ('great_international', '0063_auto_20190806_1416'), + ] + + operations = [ + migrations.CreateModel( + name='CapitalInvestContactFormPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), + ('service_name', models.CharField(choices=[('FIND_A_SUPPLIER', 'Find a Supplier'), ('EXPORT_READINESS', 'Export Readiness'), ('INVEST', 'Invest'), ('COMPONENTS', 'Components'), ('GREAT_INTERNATIONAL', 'Great International')], db_index=True, max_length=100, null=True)), + ('uses_tree_based_routing', models.BooleanField(default=False, help_text="Allow this page's URL to be determined by its slug, and the slugs of its ancestors in the page tree.", verbose_name='tree-based routing enabled')), + ('breadcrumbs_label', models.CharField(max_length=255)), + ('breadcrumbs_label_en_gb', models.CharField(max_length=255, null=True)), + ('breadcrumbs_label_de', models.CharField(max_length=255, null=True)), + ('breadcrumbs_label_ja', models.CharField(max_length=255, null=True)), + ('breadcrumbs_label_zh_hans', models.CharField(max_length=255, null=True)), + ('breadcrumbs_label_fr', models.CharField(max_length=255, null=True)), + ('breadcrumbs_label_es', models.CharField(max_length=255, null=True)), + ('breadcrumbs_label_pt', models.CharField(max_length=255, null=True)), + ('breadcrumbs_label_ar', models.CharField(max_length=255, null=True)), + ('heading', models.CharField(max_length=255)), + ('heading_en_gb', models.CharField(max_length=255, null=True)), + ('heading_de', models.CharField(max_length=255, null=True)), + ('heading_ja', models.CharField(max_length=255, null=True)), + ('heading_zh_hans', models.CharField(max_length=255, null=True)), + ('heading_fr', models.CharField(max_length=255, null=True)), + ('heading_es', models.CharField(max_length=255, null=True)), + ('heading_pt', models.CharField(max_length=255, null=True)), + ('heading_ar', models.CharField(max_length=255, null=True)), + ('intro', core.model_fields.MarkdownField(blank=True, validators=[core.validators.slug_hyperlinks])), + ('intro_en_gb', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('intro_de', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('intro_ja', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('intro_zh_hans', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('intro_fr', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('intro_es', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('intro_pt', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('intro_ar', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('cta_text', models.CharField(blank=True, max_length=255)), + ('cta_text_en_gb', models.CharField(blank=True, max_length=255, null=True)), + ('cta_text_de', models.CharField(blank=True, max_length=255, null=True)), + ('cta_text_ja', models.CharField(blank=True, max_length=255, null=True)), + ('cta_text_zh_hans', models.CharField(blank=True, max_length=255, null=True)), + ('cta_text_fr', models.CharField(blank=True, max_length=255, null=True)), + ('cta_text_es', models.CharField(blank=True, max_length=255, null=True)), + ('cta_text_pt', models.CharField(blank=True, max_length=255, null=True)), + ('cta_text_ar', models.CharField(blank=True, max_length=255, null=True)), + ], + options={ + 'abstract': False, + }, + bases=(great_international.panels.capital_invest.CapitalInvestContactFormPagePanels, core.models.WagtailAdminExclusivePageMixin, 'wagtailcore.page'), + ), + ] diff --git a/great_international/models/capital_invest.py b/great_international/models/capital_invest.py index 71b87deb..43cf5491 100644 --- a/great_international/models/capital_invest.py +++ b/great_international/models/capital_invest.py @@ -127,6 +127,12 @@ class InternationalCapitalInvestLandingPage( parent_page_types = ['great_international.InternationalHomePage'] + @classmethod + def allowed_subpage_models(cls): + return [ + CapitalInvestContactFormPage + ] + hero_title = models.CharField(max_length=255) hero_image = models.ForeignKey( 'wagtailimages.Image', @@ -686,3 +692,15 @@ class CapitalInvestOpportunityPage( contact_title = models.CharField(max_length=255, blank=True) contact_text = MarkdownField(blank=True) + + +class CapitalInvestContactFormPage( + panels.CapitalInvestContactFormPagePanels, WagtailAdminExclusivePageMixin, BaseInternationalPage +): + slug_identity = 'contact' + parent_page_types = ['great_international.InternationalCapitalInvestLandingPage'] + + breadcrumbs_label = models.CharField(max_length=255) + heading = models.CharField(max_length=255) + intro = MarkdownField(blank=True) + cta_text = models.CharField(max_length=255, blank=True) diff --git a/great_international/models/great_international.py b/great_international/models/great_international.py index 13d054ba..01f3ebf1 100644 --- a/great_international/models/great_international.py +++ b/great_international/models/great_international.py @@ -514,6 +514,7 @@ def allowed_subpage_models(cls): capital_invest_models.InternationalCapitalInvestLandingPage, capital_invest_models.CapitalInvestOpportunityListingPage, capital_invest_models.CapitalInvestRegionPage, + capital_invest_models.CapitalInvestContactFormPage, invest_models.InvestInternationalHomePage, fas_models.InternationalTradeHomePage ] diff --git a/great_international/panels/capital_invest.py b/great_international/panels/capital_invest.py index 7b2b66ac..4ab609f3 100644 --- a/great_international/panels/capital_invest.py +++ b/great_international/panels/capital_invest.py @@ -505,3 +505,22 @@ class CapitalInvestOpportunityPagePanels: content_panels=content_panels, settings_panels=settings_panels, ) + + +class CapitalInvestContactFormPagePanels: + content_panels = [ + FieldPanel('breadcrumbs_label'), + FieldPanel('heading'), + FieldPanel('intro'), + FieldPanel('cta_text'), + ] + + settings_panels = [ + FieldPanel('title_en_gb'), + FieldPanel('slug'), + ] + + edit_handler = make_translated_interface( + content_panels=content_panels, + settings_panels=settings_panels, + ) diff --git a/great_international/serializers.py b/great_international/serializers.py index 1a35d17c..a4055870 100644 --- a/great_international/serializers.py +++ b/great_international/serializers.py @@ -2018,3 +2018,10 @@ def get_about_uk_articles_fields(self, instance): contact_us_section_summary = core_fields.MarkdownToHTMLField() contact_us_section_cta_text = serializers.CharField() contact_us_section_cta_link = serializers.CharField() + + +class CapitalInvestContactFormPageSerializer(BasePageSerializer): + breadcrumbs_label = serializers.CharField() + heading = serializers.CharField() + intro = core_fields.MarkdownToHTMLField() + cta_text = serializers.CharField() diff --git a/great_international/translation.py b/great_international/translation.py index ee62be09..fff31e31 100644 --- a/great_international/translation.py +++ b/great_international/translation.py @@ -557,7 +557,7 @@ class CapitalInvestOpportunityPageTranslationOptions( @register(capital_invest.CapitalInvestRelatedRegions) -class RelatedRegionsSerializer( +class RelatedRegionsTranslationOptions( BaseTranslationOptions): fields = ( 'page', @@ -565,7 +565,7 @@ class RelatedRegionsSerializer( @register(capital_invest.CapitalInvestRelatedSectors) -class RelatedSectorsSerializer( +class RelatedSectorsTranslationOptions( BaseTranslationOptions): fields = ( 'page', @@ -573,7 +573,7 @@ class RelatedSectorsSerializer( @register(capital_invest.CapitalInvestRegionCardFieldsSummary) -class CapitalInvestRegionCardFieldSerializer( +class CapitalInvestRegionCardFieldTranslationOptions( BaseTranslationOptions): fields = ( 'page', @@ -581,7 +581,7 @@ class CapitalInvestRegionCardFieldSerializer( @register(capital_invest.CapitalInvestHomesInEnglandCardFieldsSummary) -class CapitalInvestHomesInEnglandCardFieldsSummarySerializer( +class CapitalInvestHomesInEnglandCardFieldsSummaryTranslationOptions( BaseTranslationOptions): fields = ( 'page', @@ -879,7 +879,7 @@ class AboutDitServicesPageTranslationOptions( @register(great_international.AboutDitServicesFields) -class AboutDitServicesFieldsSerializer( +class AboutDitServicesFieldsTranslationOptions( BaseTranslationOptions ): fields = ( @@ -986,9 +986,21 @@ class AboutUkWhyChooseTheUkPageTranslationOptions( @register(great_international.AboutUkArticlesFields) -class AboutUkArticlesFieldsSerializer( +class AboutUkArticlesFieldsTranslationOptions( BaseTranslationOptions ): fields = ( 'page', ) + + +@register(capital_invest.CapitalInvestContactFormPage) +class CapitalInvestContactFormPageTranslationOptions( + BaseTranslationOptions +): + fields = ( + 'breadcrumbs_label', + 'heading', + 'intro', + 'cta_text', + ) diff --git a/tests/great_international/test_models.py b/tests/great_international/test_models.py index 16ddd3e6..a0f81674 100644 --- a/tests/great_international/test_models.py +++ b/tests/great_international/test_models.py @@ -24,6 +24,7 @@ def test_models_hierarchy(): capital_invest.InternationalCapitalInvestLandingPage, capital_invest.CapitalInvestOpportunityListingPage, capital_invest.CapitalInvestRegionPage, + capital_invest.CapitalInvestContactFormPage, invest.InvestInternationalHomePage, find_a_supplier.InternationalTradeHomePage ] @@ -74,6 +75,7 @@ def test_models_hierarchy(): assert capital_invest.CapitalInvestOpportunityListingPage.allowed_subpage_models() == [ capital_invest.CapitalInvestOpportunityPage, ] + assert capital_invest.CapitalInvestContactFormPage.allowed_subpage_models() == [] assert great_international.InternationalSectorPage.allowed_subpage_models() == [ great_international.InternationalSubSectorPage, ] From 3d12d211cdae9ba46d18dad2cd276d3f67fd4412 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Thu, 8 Aug 2019 12:16:41 +0100 Subject: [PATCH 02/22] Updated migration and added caching subscriber --- great_international/apps.py | 1 + great_international/cache.py | 7 ++++++ ...y => 0066_capitalinvestcontactformpage.py} | 22 +++++++++---------- great_international/models/capital_invest.py | 4 ++-- .../models/great_international.py | 1 - 5 files changed, 21 insertions(+), 14 deletions(-) rename great_international/migrations/{0064_capitalinvestcontactformpage.py => 0066_capitalinvestcontactformpage.py} (80%) diff --git a/great_international/apps.py b/great_international/apps.py index d0754d49..4c52eed0 100644 --- a/great_international/apps.py +++ b/great_international/apps.py @@ -36,6 +36,7 @@ def ready(self): cache.AboutDitServicesPageSubscriber.subscribe() cache.AboutUkLandingPageSubscriber.subscribe() cache.AboutUkWhyChooseTheUkPageSubscriber.subscribe() + cache.CapitalInvestContactFormPageSubscriber.subscribe() # tags inheritance signals post_save.connect( receiver=signals.inherit_tags_from_parent, diff --git a/great_international/cache.py b/great_international/cache.py index 1a2bd147..7fc96b1e 100644 --- a/great_international/cache.py +++ b/great_international/cache.py @@ -239,3 +239,10 @@ class AboutUkWhyChooseTheUkPageSubscriber( ): model = great_international.AboutUkWhyChooseTheUkPage subscriptions = [] + + +class CapitalInvestContactFormPageSubscriber( + AbstractDatabaseCacheSubscriber +): + model = capital_invest.CapitalInvestContactFormPage + subscriptions = [] diff --git a/great_international/migrations/0064_capitalinvestcontactformpage.py b/great_international/migrations/0066_capitalinvestcontactformpage.py similarity index 80% rename from great_international/migrations/0064_capitalinvestcontactformpage.py rename to great_international/migrations/0066_capitalinvestcontactformpage.py index ca246e20..17a72e40 100644 --- a/great_international/migrations/0064_capitalinvestcontactformpage.py +++ b/great_international/migrations/0066_capitalinvestcontactformpage.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.3 on 2019-08-07 08:07 +# Generated by Django 2.2.3 on 2019-08-08 11:02 import core.model_fields import core.models @@ -12,7 +12,7 @@ class Migration(migrations.Migration): dependencies = [ ('wagtailcore', '0041_group_collection_permissions_verbose_name_plural'), - ('great_international', '0063_auto_20190806_1416'), + ('great_international', '0065_auto_20190808_1032'), ] operations = [ @@ -22,15 +22,15 @@ class Migration(migrations.Migration): ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), ('service_name', models.CharField(choices=[('FIND_A_SUPPLIER', 'Find a Supplier'), ('EXPORT_READINESS', 'Export Readiness'), ('INVEST', 'Invest'), ('COMPONENTS', 'Components'), ('GREAT_INTERNATIONAL', 'Great International')], db_index=True, max_length=100, null=True)), ('uses_tree_based_routing', models.BooleanField(default=False, help_text="Allow this page's URL to be determined by its slug, and the slugs of its ancestors in the page tree.", verbose_name='tree-based routing enabled')), - ('breadcrumbs_label', models.CharField(max_length=255)), - ('breadcrumbs_label_en_gb', models.CharField(max_length=255, null=True)), - ('breadcrumbs_label_de', models.CharField(max_length=255, null=True)), - ('breadcrumbs_label_ja', models.CharField(max_length=255, null=True)), - ('breadcrumbs_label_zh_hans', models.CharField(max_length=255, null=True)), - ('breadcrumbs_label_fr', models.CharField(max_length=255, null=True)), - ('breadcrumbs_label_es', models.CharField(max_length=255, null=True)), - ('breadcrumbs_label_pt', models.CharField(max_length=255, null=True)), - ('breadcrumbs_label_ar', models.CharField(max_length=255, null=True)), + ('breadcrumbs_label', models.CharField(blank=True, max_length=255)), + ('breadcrumbs_label_en_gb', models.CharField(blank=True, max_length=255, null=True)), + ('breadcrumbs_label_de', models.CharField(blank=True, max_length=255, null=True)), + ('breadcrumbs_label_ja', models.CharField(blank=True, max_length=255, null=True)), + ('breadcrumbs_label_zh_hans', models.CharField(blank=True, max_length=255, null=True)), + ('breadcrumbs_label_fr', models.CharField(blank=True, max_length=255, null=True)), + ('breadcrumbs_label_es', models.CharField(blank=True, max_length=255, null=True)), + ('breadcrumbs_label_pt', models.CharField(blank=True, max_length=255, null=True)), + ('breadcrumbs_label_ar', models.CharField(blank=True, max_length=255, null=True)), ('heading', models.CharField(max_length=255)), ('heading_en_gb', models.CharField(max_length=255, null=True)), ('heading_de', models.CharField(max_length=255, null=True)), diff --git a/great_international/models/capital_invest.py b/great_international/models/capital_invest.py index 43cf5491..d745d112 100644 --- a/great_international/models/capital_invest.py +++ b/great_international/models/capital_invest.py @@ -697,10 +697,10 @@ class CapitalInvestOpportunityPage( class CapitalInvestContactFormPage( panels.CapitalInvestContactFormPagePanels, WagtailAdminExclusivePageMixin, BaseInternationalPage ): - slug_identity = 'contact' parent_page_types = ['great_international.InternationalCapitalInvestLandingPage'] + slug_identity = 'contact' - breadcrumbs_label = models.CharField(max_length=255) + breadcrumbs_label = models.CharField(max_length=255, blank=True) heading = models.CharField(max_length=255) intro = MarkdownField(blank=True) cta_text = models.CharField(max_length=255, blank=True) diff --git a/great_international/models/great_international.py b/great_international/models/great_international.py index 01f3ebf1..13d054ba 100644 --- a/great_international/models/great_international.py +++ b/great_international/models/great_international.py @@ -514,7 +514,6 @@ def allowed_subpage_models(cls): capital_invest_models.InternationalCapitalInvestLandingPage, capital_invest_models.CapitalInvestOpportunityListingPage, capital_invest_models.CapitalInvestRegionPage, - capital_invest_models.CapitalInvestContactFormPage, invest_models.InvestInternationalHomePage, fas_models.InternationalTradeHomePage ] From 8b965202b7e9db26296efe3c2beecae855f66a0c Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Thu, 8 Aug 2019 15:15:38 +0100 Subject: [PATCH 03/22] Success form added and updates --- core/serializer_mapping.py | 1 + great_international/apps.py | 1 + great_international/cache.py | 7 +++ ...067_capitalinvestcontactformsuccesspage.py | 49 ++++++++++++++++ .../migrations/0068_auto_20190808_1414.py | 58 +++++++++++++++++++ great_international/models/capital_invest.py | 18 +++++- great_international/panels/capital_invest.py | 17 ++++++ great_international/serializers.py | 5 ++ great_international/translation.py | 10 ++++ 9 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 great_international/migrations/0067_capitalinvestcontactformsuccesspage.py create mode 100644 great_international/migrations/0068_auto_20190808_1414.py diff --git a/core/serializer_mapping.py b/core/serializer_mapping.py index eeda3032..e3b32ce8 100644 --- a/core/serializer_mapping.py +++ b/core/serializer_mapping.py @@ -60,6 +60,7 @@ great_international.models.capital_invest.CapitalInvestOpportunityListingPage: great_international.serializers.CapitalInvestOpportunityListingSerializer, # NOQA great_international.models.capital_invest.CapitalInvestOpportunityPage: great_international.serializers.CapitalInvestOpportunityPageSerializer, # NOQA great_international.models.capital_invest.CapitalInvestContactFormPage: great_international.serializers.CapitalInvestContactFormPageSerializer, # NOQA + great_international.models.capital_invest.CapitalInvestContactFormSuccessPage: great_international.serializers.CapitalInvestContactFormSuccessPageSerializer, # NOQA great_international.models.invest.InvestInternationalHomePage: great_international.serializers.InvestInternationalHomePageSerializer, # NOQA great_international.models.invest.InvestHighPotentialOpportunityFormSuccessPage: great_international.serializers.InvestHighPotentialOpportunityFormSuccessPageSerializer, # NOQA great_international.models.invest.InvestHighPotentialOpportunityFormPage: great_international.serializers.InvestHighPotentialOpportunityFormPageSerializer, # NOQA diff --git a/great_international/apps.py b/great_international/apps.py index 4c52eed0..7397d24c 100644 --- a/great_international/apps.py +++ b/great_international/apps.py @@ -37,6 +37,7 @@ def ready(self): cache.AboutUkLandingPageSubscriber.subscribe() cache.AboutUkWhyChooseTheUkPageSubscriber.subscribe() cache.CapitalInvestContactFormPageSubscriber.subscribe() + cache.CapitalInvestContactFormSuccessPageSubscriber.subscribe() # tags inheritance signals post_save.connect( receiver=signals.inherit_tags_from_parent, diff --git a/great_international/cache.py b/great_international/cache.py index 7fc96b1e..114e7c63 100644 --- a/great_international/cache.py +++ b/great_international/cache.py @@ -246,3 +246,10 @@ class CapitalInvestContactFormPageSubscriber( ): model = capital_invest.CapitalInvestContactFormPage subscriptions = [] + + +class CapitalInvestContactFormSuccessPageSubscriber( + AbstractDatabaseCacheSubscriber +): + model = capital_invest.CapitalInvestContactFormSuccessPage + subscriptions = [] diff --git a/great_international/migrations/0067_capitalinvestcontactformsuccesspage.py b/great_international/migrations/0067_capitalinvestcontactformsuccesspage.py new file mode 100644 index 00000000..65e69f30 --- /dev/null +++ b/great_international/migrations/0067_capitalinvestcontactformsuccesspage.py @@ -0,0 +1,49 @@ +# Generated by Django 2.2.3 on 2019-08-08 12:06 + +import core.model_fields +import core.models +import core.validators +from django.db import migrations, models +import django.db.models.deletion +import great_international.panels.capital_invest + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0041_group_collection_permissions_verbose_name_plural'), + ('great_international', '0066_capitalinvestcontactformpage'), + ] + + operations = [ + migrations.CreateModel( + name='CapitalInvestContactFormSuccessPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), + ('service_name', models.CharField(choices=[('FIND_A_SUPPLIER', 'Find a Supplier'), ('EXPORT_READINESS', 'Export Readiness'), ('INVEST', 'Invest'), ('COMPONENTS', 'Components'), ('GREAT_INTERNATIONAL', 'Great International')], db_index=True, max_length=100, null=True)), + ('uses_tree_based_routing', models.BooleanField(default=False, help_text="Allow this page's URL to be determined by its slug, and the slugs of its ancestors in the page tree.", verbose_name='tree-based routing enabled')), + ('large_text', models.CharField(max_length=255)), + ('large_text_en_gb', models.CharField(max_length=255, null=True)), + ('large_text_de', models.CharField(max_length=255, null=True)), + ('large_text_ja', models.CharField(max_length=255, null=True)), + ('large_text_zh_hans', models.CharField(max_length=255, null=True)), + ('large_text_fr', models.CharField(max_length=255, null=True)), + ('large_text_es', models.CharField(max_length=255, null=True)), + ('large_text_pt', models.CharField(max_length=255, null=True)), + ('large_text_ar', models.CharField(max_length=255, null=True)), + ('small_text', core.model_fields.MarkdownField(blank=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_en_gb', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_de', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_ja', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_zh_hans', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_fr', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_es', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_pt', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_ar', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ], + options={ + 'abstract': False, + }, + bases=(great_international.panels.capital_invest.CapitalInvestContactFormSuccessPagePanels, core.models.WagtailAdminExclusivePageMixin, 'wagtailcore.page'), + ), + ] diff --git a/great_international/migrations/0068_auto_20190808_1414.py b/great_international/migrations/0068_auto_20190808_1414.py new file mode 100644 index 00000000..c09f9e4c --- /dev/null +++ b/great_international/migrations/0068_auto_20190808_1414.py @@ -0,0 +1,58 @@ +# Generated by Django 2.2.3 on 2019-08-08 14:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('great_international', '0067_capitalinvestcontactformsuccesspage'), + ] + + operations = [ + migrations.AlterField( + model_name='capitalinvestcontactformpage', + name='cta_text', + field=models.CharField(max_length=255), + ), + migrations.AlterField( + model_name='capitalinvestcontactformpage', + name='cta_text_ar', + field=models.CharField(max_length=255, null=True), + ), + migrations.AlterField( + model_name='capitalinvestcontactformpage', + name='cta_text_de', + field=models.CharField(max_length=255, null=True), + ), + migrations.AlterField( + model_name='capitalinvestcontactformpage', + name='cta_text_en_gb', + field=models.CharField(max_length=255, null=True), + ), + migrations.AlterField( + model_name='capitalinvestcontactformpage', + name='cta_text_es', + field=models.CharField(max_length=255, null=True), + ), + migrations.AlterField( + model_name='capitalinvestcontactformpage', + name='cta_text_fr', + field=models.CharField(max_length=255, null=True), + ), + migrations.AlterField( + model_name='capitalinvestcontactformpage', + name='cta_text_ja', + field=models.CharField(max_length=255, null=True), + ), + migrations.AlterField( + model_name='capitalinvestcontactformpage', + name='cta_text_pt', + field=models.CharField(max_length=255, null=True), + ), + migrations.AlterField( + model_name='capitalinvestcontactformpage', + name='cta_text_zh_hans', + field=models.CharField(max_length=255, null=True), + ), + ] diff --git a/great_international/models/capital_invest.py b/great_international/models/capital_invest.py index d745d112..411177c1 100644 --- a/great_international/models/capital_invest.py +++ b/great_international/models/capital_invest.py @@ -703,4 +703,20 @@ class CapitalInvestContactFormPage( breadcrumbs_label = models.CharField(max_length=255, blank=True) heading = models.CharField(max_length=255) intro = MarkdownField(blank=True) - cta_text = models.CharField(max_length=255, blank=True) + cta_text = models.CharField(max_length=255) + + @classmethod + def allowed_subpage_models(cls): + return [ + CapitalInvestContactFormSuccessPage + ] + + +class CapitalInvestContactFormSuccessPage( + panels.CapitalInvestContactFormSuccessPagePanels, WagtailAdminExclusivePageMixin, BaseInternationalPage +): + parent_page_types = ['great_international.CapitalInvestContactFormPage'] + slug_identity = 'success' + + large_text = models.CharField(max_length=255) + small_text = MarkdownField(blank=True) diff --git a/great_international/panels/capital_invest.py b/great_international/panels/capital_invest.py index 4ab609f3..7eeba479 100644 --- a/great_international/panels/capital_invest.py +++ b/great_international/panels/capital_invest.py @@ -524,3 +524,20 @@ class CapitalInvestContactFormPagePanels: content_panels=content_panels, settings_panels=settings_panels, ) + + +class CapitalInvestContactFormSuccessPagePanels: + content_panels = [ + FieldPanel('large_text'), + FieldPanel('small_text'), + ] + + settings_panels = [ + FieldPanel('title_en_gb'), + FieldPanel('slug'), + ] + + edit_handler = make_translated_interface( + content_panels=content_panels, + settings_panels=settings_panels, + ) diff --git a/great_international/serializers.py b/great_international/serializers.py index a4055870..75d548a9 100644 --- a/great_international/serializers.py +++ b/great_international/serializers.py @@ -2025,3 +2025,8 @@ class CapitalInvestContactFormPageSerializer(BasePageSerializer): heading = serializers.CharField() intro = core_fields.MarkdownToHTMLField() cta_text = serializers.CharField() + + +class CapitalInvestContactFormSuccessPageSerializer(BasePageSerializer): + large_text = serializers.CharField() + small_text = core_fields.MarkdownToHTMLField() diff --git a/great_international/translation.py b/great_international/translation.py index fff31e31..b6bdb2c3 100644 --- a/great_international/translation.py +++ b/great_international/translation.py @@ -1004,3 +1004,13 @@ class CapitalInvestContactFormPageTranslationOptions( 'intro', 'cta_text', ) + + +@register(capital_invest.CapitalInvestContactFormSuccessPage) +class CapitalInvestContactFormSuccessPageTranslationOptions( + BaseTranslationOptions +): + fields = ( + 'large_text', + 'small_text', + ) From fb9c780049a1a978caf2c5ecc218d6dc814e6841 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Thu, 8 Aug 2019 15:51:19 +0100 Subject: [PATCH 04/22] Merged to one migration --- ...ge_capitalinvestcontactformsuccesspage.py} | 50 ++++++++++++---- ...067_capitalinvestcontactformsuccesspage.py | 49 ---------------- .../migrations/0068_auto_20190808_1414.py | 58 ------------------- 3 files changed, 40 insertions(+), 117 deletions(-) rename great_international/migrations/{0066_capitalinvestcontactformpage.py => 0066_capitalinvestcontactformpage_capitalinvestcontactformsuccesspage.py} (53%) delete mode 100644 great_international/migrations/0067_capitalinvestcontactformsuccesspage.py delete mode 100644 great_international/migrations/0068_auto_20190808_1414.py diff --git a/great_international/migrations/0066_capitalinvestcontactformpage.py b/great_international/migrations/0066_capitalinvestcontactformpage_capitalinvestcontactformsuccesspage.py similarity index 53% rename from great_international/migrations/0066_capitalinvestcontactformpage.py rename to great_international/migrations/0066_capitalinvestcontactformpage_capitalinvestcontactformsuccesspage.py index 17a72e40..acc8f491 100644 --- a/great_international/migrations/0066_capitalinvestcontactformpage.py +++ b/great_international/migrations/0066_capitalinvestcontactformpage_capitalinvestcontactformsuccesspage.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.3 on 2019-08-08 11:02 +# Generated by Django 2.2.3 on 2019-08-08 14:51 import core.model_fields import core.models @@ -49,19 +49,49 @@ class Migration(migrations.Migration): ('intro_es', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), ('intro_pt', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), ('intro_ar', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), - ('cta_text', models.CharField(blank=True, max_length=255)), - ('cta_text_en_gb', models.CharField(blank=True, max_length=255, null=True)), - ('cta_text_de', models.CharField(blank=True, max_length=255, null=True)), - ('cta_text_ja', models.CharField(blank=True, max_length=255, null=True)), - ('cta_text_zh_hans', models.CharField(blank=True, max_length=255, null=True)), - ('cta_text_fr', models.CharField(blank=True, max_length=255, null=True)), - ('cta_text_es', models.CharField(blank=True, max_length=255, null=True)), - ('cta_text_pt', models.CharField(blank=True, max_length=255, null=True)), - ('cta_text_ar', models.CharField(blank=True, max_length=255, null=True)), + ('cta_text', models.CharField(max_length=255)), + ('cta_text_en_gb', models.CharField(max_length=255, null=True)), + ('cta_text_de', models.CharField(max_length=255, null=True)), + ('cta_text_ja', models.CharField(max_length=255, null=True)), + ('cta_text_zh_hans', models.CharField(max_length=255, null=True)), + ('cta_text_fr', models.CharField(max_length=255, null=True)), + ('cta_text_es', models.CharField(max_length=255, null=True)), + ('cta_text_pt', models.CharField(max_length=255, null=True)), + ('cta_text_ar', models.CharField(max_length=255, null=True)), ], options={ 'abstract': False, }, bases=(great_international.panels.capital_invest.CapitalInvestContactFormPagePanels, core.models.WagtailAdminExclusivePageMixin, 'wagtailcore.page'), ), + migrations.CreateModel( + name='CapitalInvestContactFormSuccessPage', + fields=[ + ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), + ('service_name', models.CharField(choices=[('FIND_A_SUPPLIER', 'Find a Supplier'), ('EXPORT_READINESS', 'Export Readiness'), ('INVEST', 'Invest'), ('COMPONENTS', 'Components'), ('GREAT_INTERNATIONAL', 'Great International')], db_index=True, max_length=100, null=True)), + ('uses_tree_based_routing', models.BooleanField(default=False, help_text="Allow this page's URL to be determined by its slug, and the slugs of its ancestors in the page tree.", verbose_name='tree-based routing enabled')), + ('large_text', models.CharField(max_length=255)), + ('large_text_en_gb', models.CharField(max_length=255, null=True)), + ('large_text_de', models.CharField(max_length=255, null=True)), + ('large_text_ja', models.CharField(max_length=255, null=True)), + ('large_text_zh_hans', models.CharField(max_length=255, null=True)), + ('large_text_fr', models.CharField(max_length=255, null=True)), + ('large_text_es', models.CharField(max_length=255, null=True)), + ('large_text_pt', models.CharField(max_length=255, null=True)), + ('large_text_ar', models.CharField(max_length=255, null=True)), + ('small_text', core.model_fields.MarkdownField(blank=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_en_gb', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_de', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_ja', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_zh_hans', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_fr', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_es', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_pt', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ('small_text_ar', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), + ], + options={ + 'abstract': False, + }, + bases=(great_international.panels.capital_invest.CapitalInvestContactFormSuccessPagePanels, core.models.WagtailAdminExclusivePageMixin, 'wagtailcore.page'), + ), ] diff --git a/great_international/migrations/0067_capitalinvestcontactformsuccesspage.py b/great_international/migrations/0067_capitalinvestcontactformsuccesspage.py deleted file mode 100644 index 65e69f30..00000000 --- a/great_international/migrations/0067_capitalinvestcontactformsuccesspage.py +++ /dev/null @@ -1,49 +0,0 @@ -# Generated by Django 2.2.3 on 2019-08-08 12:06 - -import core.model_fields -import core.models -import core.validators -from django.db import migrations, models -import django.db.models.deletion -import great_international.panels.capital_invest - - -class Migration(migrations.Migration): - - dependencies = [ - ('wagtailcore', '0041_group_collection_permissions_verbose_name_plural'), - ('great_international', '0066_capitalinvestcontactformpage'), - ] - - operations = [ - migrations.CreateModel( - name='CapitalInvestContactFormSuccessPage', - fields=[ - ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), - ('service_name', models.CharField(choices=[('FIND_A_SUPPLIER', 'Find a Supplier'), ('EXPORT_READINESS', 'Export Readiness'), ('INVEST', 'Invest'), ('COMPONENTS', 'Components'), ('GREAT_INTERNATIONAL', 'Great International')], db_index=True, max_length=100, null=True)), - ('uses_tree_based_routing', models.BooleanField(default=False, help_text="Allow this page's URL to be determined by its slug, and the slugs of its ancestors in the page tree.", verbose_name='tree-based routing enabled')), - ('large_text', models.CharField(max_length=255)), - ('large_text_en_gb', models.CharField(max_length=255, null=True)), - ('large_text_de', models.CharField(max_length=255, null=True)), - ('large_text_ja', models.CharField(max_length=255, null=True)), - ('large_text_zh_hans', models.CharField(max_length=255, null=True)), - ('large_text_fr', models.CharField(max_length=255, null=True)), - ('large_text_es', models.CharField(max_length=255, null=True)), - ('large_text_pt', models.CharField(max_length=255, null=True)), - ('large_text_ar', models.CharField(max_length=255, null=True)), - ('small_text', core.model_fields.MarkdownField(blank=True, validators=[core.validators.slug_hyperlinks])), - ('small_text_en_gb', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), - ('small_text_de', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), - ('small_text_ja', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), - ('small_text_zh_hans', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), - ('small_text_fr', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), - ('small_text_es', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), - ('small_text_pt', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), - ('small_text_ar', core.model_fields.MarkdownField(blank=True, null=True, validators=[core.validators.slug_hyperlinks])), - ], - options={ - 'abstract': False, - }, - bases=(great_international.panels.capital_invest.CapitalInvestContactFormSuccessPagePanels, core.models.WagtailAdminExclusivePageMixin, 'wagtailcore.page'), - ), - ] diff --git a/great_international/migrations/0068_auto_20190808_1414.py b/great_international/migrations/0068_auto_20190808_1414.py deleted file mode 100644 index c09f9e4c..00000000 --- a/great_international/migrations/0068_auto_20190808_1414.py +++ /dev/null @@ -1,58 +0,0 @@ -# Generated by Django 2.2.3 on 2019-08-08 14:14 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('great_international', '0067_capitalinvestcontactformsuccesspage'), - ] - - operations = [ - migrations.AlterField( - model_name='capitalinvestcontactformpage', - name='cta_text', - field=models.CharField(max_length=255), - ), - migrations.AlterField( - model_name='capitalinvestcontactformpage', - name='cta_text_ar', - field=models.CharField(max_length=255, null=True), - ), - migrations.AlterField( - model_name='capitalinvestcontactformpage', - name='cta_text_de', - field=models.CharField(max_length=255, null=True), - ), - migrations.AlterField( - model_name='capitalinvestcontactformpage', - name='cta_text_en_gb', - field=models.CharField(max_length=255, null=True), - ), - migrations.AlterField( - model_name='capitalinvestcontactformpage', - name='cta_text_es', - field=models.CharField(max_length=255, null=True), - ), - migrations.AlterField( - model_name='capitalinvestcontactformpage', - name='cta_text_fr', - field=models.CharField(max_length=255, null=True), - ), - migrations.AlterField( - model_name='capitalinvestcontactformpage', - name='cta_text_ja', - field=models.CharField(max_length=255, null=True), - ), - migrations.AlterField( - model_name='capitalinvestcontactformpage', - name='cta_text_pt', - field=models.CharField(max_length=255, null=True), - ), - migrations.AlterField( - model_name='capitalinvestcontactformpage', - name='cta_text_zh_hans', - field=models.CharField(max_length=255, null=True), - ), - ] From a30dfc65740d17e5471e8a2da112955a34fabf02 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Thu, 8 Aug 2019 16:57:21 +0100 Subject: [PATCH 05/22] Tests --- tests/great_international/test_models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/great_international/test_models.py b/tests/great_international/test_models.py index a0f81674..743367f5 100644 --- a/tests/great_international/test_models.py +++ b/tests/great_international/test_models.py @@ -24,7 +24,6 @@ def test_models_hierarchy(): capital_invest.InternationalCapitalInvestLandingPage, capital_invest.CapitalInvestOpportunityListingPage, capital_invest.CapitalInvestRegionPage, - capital_invest.CapitalInvestContactFormPage, invest.InvestInternationalHomePage, find_a_supplier.InternationalTradeHomePage ] @@ -75,7 +74,10 @@ def test_models_hierarchy(): assert capital_invest.CapitalInvestOpportunityListingPage.allowed_subpage_models() == [ capital_invest.CapitalInvestOpportunityPage, ] - assert capital_invest.CapitalInvestContactFormPage.allowed_subpage_models() == [] + assert capital_invest.CapitalInvestContactFormPage.allowed_subpage_models() == [ + capital_invest.CapitalInvestContactFormSuccessPage + ] + assert capital_invest.CapitalInvestContactFormSuccessPage.allowed_subpage_models() == [] assert great_international.InternationalSectorPage.allowed_subpage_models() == [ great_international.InternationalSubSectorPage, ] From c4cbe00f4a0034a1eabcacbe719cae7339c30c0e Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Thu, 8 Aug 2019 17:21:54 +0100 Subject: [PATCH 06/22] Added new models to tests --- tests/great_international/test_models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/great_international/test_models.py b/tests/great_international/test_models.py index 743367f5..00eb378c 100644 --- a/tests/great_international/test_models.py +++ b/tests/great_international/test_models.py @@ -24,6 +24,8 @@ def test_models_hierarchy(): capital_invest.InternationalCapitalInvestLandingPage, capital_invest.CapitalInvestOpportunityListingPage, capital_invest.CapitalInvestRegionPage, + capital_invest.CapitalInvestContactFormPage, + capital_invest.CapitalInvestContactFormSuccessPage, invest.InvestInternationalHomePage, find_a_supplier.InternationalTradeHomePage ] From 4bc1a203c56ce5a03603e0b76e8160115e159547 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Fri, 9 Aug 2019 09:15:39 +0100 Subject: [PATCH 07/22] Updated db template --- db_template.sql | 169 ++++++++++++++++++++++- tests/great_international/test_models.py | 2 - 2 files changed, 166 insertions(+), 5 deletions(-) diff --git a/db_template.sql b/db_template.sql index 59548abb..c5f6c0f9 100644 --- a/db_template.sql +++ b/db_template.sql @@ -2988,6 +2988,82 @@ CREATE TABLE public.great_international_aboutukwhychoosetheukpage ( ); +-- +-- Name: great_international_capitalinvestcontactformpage; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.great_international_capitalinvestcontactformpage ( + page_ptr_id integer NOT NULL, + service_name character varying(100), + uses_tree_based_routing boolean NOT NULL, + breadcrumbs_label character varying(255) NOT NULL, + breadcrumbs_label_en_gb character varying(255), + breadcrumbs_label_de character varying(255), + breadcrumbs_label_ja character varying(255), + breadcrumbs_label_zh_hans character varying(255), + breadcrumbs_label_fr character varying(255), + breadcrumbs_label_es character varying(255), + breadcrumbs_label_pt character varying(255), + breadcrumbs_label_ar character varying(255), + heading character varying(255) NOT NULL, + heading_en_gb character varying(255), + heading_de character varying(255), + heading_ja character varying(255), + heading_zh_hans character varying(255), + heading_fr character varying(255), + heading_es character varying(255), + heading_pt character varying(255), + heading_ar character varying(255), + intro text NOT NULL, + intro_en_gb text, + intro_de text, + intro_ja text, + intro_zh_hans text, + intro_fr text, + intro_es text, + intro_pt text, + intro_ar text, + cta_text character varying(255) NOT NULL, + cta_text_en_gb character varying(255), + cta_text_de character varying(255), + cta_text_ja character varying(255), + cta_text_zh_hans character varying(255), + cta_text_fr character varying(255), + cta_text_es character varying(255), + cta_text_pt character varying(255), + cta_text_ar character varying(255) +); + + +-- +-- Name: great_international_capitalinvestcontactformsuccesspage; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.great_international_capitalinvestcontactformsuccesspage ( + page_ptr_id integer NOT NULL, + service_name character varying(100), + uses_tree_based_routing boolean NOT NULL, + large_text character varying(255) NOT NULL, + large_text_en_gb character varying(255), + large_text_de character varying(255), + large_text_ja character varying(255), + large_text_zh_hans character varying(255), + large_text_fr character varying(255), + large_text_es character varying(255), + large_text_pt character varying(255), + large_text_ar character varying(255), + small_text text NOT NULL, + small_text_en_gb text, + small_text_de text, + small_text_ja text, + small_text_zh_hans text, + small_text_fr text, + small_text_es text, + small_text_pt text, + small_text_ar text +); + + -- -- Name: great_international_capitalinvesthomesinenglandcardfieldssu8d44; Type: TABLE; Schema: public; Owner: - -- @@ -12566,6 +12642,14 @@ COPY public.auth_permission (id, name, content_type_id, codename) FROM stdin; 475 Can change invest region page 112 change_investregionpage 476 Can delete invest region page 112 delete_investregionpage 477 Can view invest region page 112 view_investregionpage +478 Can add capital invest contact form page 120 add_capitalinvestcontactformpage +479 Can change capital invest contact form page 120 change_capitalinvestcontactformpage +480 Can delete capital invest contact form page 120 delete_capitalinvestcontactformpage +481 Can view capital invest contact form page 120 view_capitalinvestcontactformpage +482 Can add capital invest contact form success page 121 add_capitalinvestcontactformsuccesspage +483 Can change capital invest contact form success page 121 change_capitalinvestcontactformsuccesspage +484 Can delete capital invest contact form success page 121 delete_capitalinvestcontactformsuccesspage +485 Can view capital invest contact form success page 121 view_capitalinvestcontactformsuccesspage \. @@ -12773,6 +12857,8 @@ COPY public.django_content_type (id, app_label, model) FROM stdin; 118 great_international aboutuklandingpage 119 great_international aboutukarticlesfields 112 great_international investregionpage +120 great_international capitalinvestcontactformpage +121 great_international capitalinvestcontactformsuccesspage \. @@ -13140,6 +13226,7 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin; 357 great_international 0063_auto_20190807_1504 2019-08-08 10:30:16.491643+01 358 great_international 0064_merge_20190808_0928 2019-08-08 10:30:16.542222+01 359 great_international 0065_auto_20190808_1032 2019-08-08 11:37:15.180475+01 +360 great_international 0066_capitalinvestcontactformpage_capitalinvestcontactformsuccesspage 2019-08-09 09:15:15.500538+01 \. @@ -13495,6 +13582,22 @@ COPY public.great_international_aboutukwhychoosetheukpage (page_ptr_id, service_ \. +-- +-- Data for Name: great_international_capitalinvestcontactformpage; Type: TABLE DATA; Schema: public; Owner: - +-- + +COPY public.great_international_capitalinvestcontactformpage (page_ptr_id, service_name, uses_tree_based_routing, breadcrumbs_label, breadcrumbs_label_en_gb, breadcrumbs_label_de, breadcrumbs_label_ja, breadcrumbs_label_zh_hans, breadcrumbs_label_fr, breadcrumbs_label_es, breadcrumbs_label_pt, breadcrumbs_label_ar, heading, heading_en_gb, heading_de, heading_ja, heading_zh_hans, heading_fr, heading_es, heading_pt, heading_ar, intro, intro_en_gb, intro_de, intro_ja, intro_zh_hans, intro_fr, intro_es, intro_pt, intro_ar, cta_text, cta_text_en_gb, cta_text_de, cta_text_ja, cta_text_zh_hans, cta_text_fr, cta_text_es, cta_text_pt, cta_text_ar) FROM stdin; +\. + + +-- +-- Data for Name: great_international_capitalinvestcontactformsuccesspage; Type: TABLE DATA; Schema: public; Owner: - +-- + +COPY public.great_international_capitalinvestcontactformsuccesspage (page_ptr_id, service_name, uses_tree_based_routing, large_text, large_text_en_gb, large_text_de, large_text_ja, large_text_zh_hans, large_text_fr, large_text_es, large_text_pt, large_text_ar, small_text, small_text_en_gb, small_text_de, small_text_ja, small_text_zh_hans, small_text_fr, small_text_es, small_text_pt, small_text_ar) FROM stdin; +\. + + -- -- Data for Name: great_international_capitalinvesthomesinenglandcardfieldssu8d44; Type: TABLE DATA; Schema: public; Owner: - -- @@ -14153,7 +14256,7 @@ SELECT pg_catalog.setval('public.auth_group_permissions_id_seq', 20, true); -- Name: auth_permission_id_seq; Type: SEQUENCE SET; Schema: public; Owner: - -- -SELECT pg_catalog.setval('public.auth_permission_id_seq', 477, true); +SELECT pg_catalog.setval('public.auth_permission_id_seq', 485, true); -- @@ -14216,14 +14319,14 @@ SELECT pg_catalog.setval('public.django_admin_log_id_seq', 1, false); -- Name: django_content_type_id_seq; Type: SEQUENCE SET; Schema: public; Owner: - -- -SELECT pg_catalog.setval('public.django_content_type_id_seq', 119, true); +SELECT pg_catalog.setval('public.django_content_type_id_seq', 121, true); -- -- Name: django_migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: - -- -SELECT pg_catalog.setval('public.django_migrations_id_seq', 359, true); +SELECT pg_catalog.setval('public.django_migrations_id_seq', 360, true); -- @@ -15124,6 +15227,22 @@ ALTER TABLE ONLY public.great_international_aboutukwhychoosetheukpage ADD CONSTRAINT great_international_aboutukwhychoosetheukpage_pkey PRIMARY KEY (page_ptr_id); +-- +-- Name: great_international_capitalinvestcontactformpage great_international_capitalinvestcontactformpage_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.great_international_capitalinvestcontactformpage + ADD CONSTRAINT great_international_capitalinvestcontactformpage_pkey PRIMARY KEY (page_ptr_id); + + +-- +-- Name: great_international_capitalinvestcontactformsuccesspage great_international_capitalinvestcontactformsuccesspage_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.great_international_capitalinvestcontactformsuccesspage + ADD CONSTRAINT great_international_capitalinvestcontactformsuccesspage_pkey PRIMARY KEY (page_ptr_id); + + -- -- Name: great_international_capitalinvesthomesinenglandcardfieldssu8d44 great_international_capitalinvesthomesinenglandcardfieldss_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -18635,6 +18754,20 @@ CREATE INDEX great_international_aboutuklandingpage_hero_image_id_6da7f8a1 ON pu CREATE INDEX great_international_aboutuklandingpage_service_name_441d14f1 ON public.great_international_aboutuklandingpage USING btree (service_name); +-- +-- Name: great_international_capi_service_name_04b98f69_like; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX great_international_capi_service_name_04b98f69_like ON public.great_international_capitalinvestcontactformsuccesspage USING btree (service_name varchar_pattern_ops); + + +-- +-- Name: great_international_capi_service_name_0867015e_like; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX great_international_capi_service_name_0867015e_like ON public.great_international_capitalinvestcontactformpage USING btree (service_name varchar_pattern_ops); + + -- -- Name: great_international_capi_service_name_a0c9c921_like; Type: INDEX; Schema: public; Owner: - -- @@ -19958,6 +20091,20 @@ CREATE INDEX great_international_capita_sector_icon_pt_id_bf4f43c2 ON public.gre CREATE INDEX great_international_capita_sector_icon_zh_hans_id_65d6dab1 ON public.great_international_capitalinvestopportunitypage USING btree (sector_icon_zh_hans_id); +-- +-- Name: great_international_capita_service_name_04b98f69; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX great_international_capita_service_name_04b98f69 ON public.great_international_capitalinvestcontactformsuccesspage USING btree (service_name); + + +-- +-- Name: great_international_capita_service_name_0867015e; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX great_international_capita_service_name_0867015e ON public.great_international_capitalinvestcontactformpage USING btree (service_name); + + -- -- Name: great_international_capita_service_name_a0c9c921; Type: INDEX; Schema: public; Owner: - -- @@ -39690,6 +39837,14 @@ ALTER TABLE ONLY public.great_international_investhighpotentialopportunityformsu ADD CONSTRAINT great_international__page_ptr_id_4e2e59c3_fk_wagtailco FOREIGN KEY (page_ptr_id) REFERENCES public.wagtailcore_page(id) DEFERRABLE INITIALLY DEFERRED; +-- +-- Name: great_international_capitalinvestcontactformpage great_international__page_ptr_id_4f703dde_fk_wagtailco; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.great_international_capitalinvestcontactformpage + ADD CONSTRAINT great_international__page_ptr_id_4f703dde_fk_wagtailco FOREIGN KEY (page_ptr_id) REFERENCES public.wagtailcore_page(id) DEFERRABLE INITIALLY DEFERRED; + + -- -- Name: great_international_internationaleuexitformpage great_international__page_ptr_id_6d7c3ad3_fk_wagtailco; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -39866,6 +40021,14 @@ ALTER TABLE ONLY public.great_international_internationalhomepage ADD CONSTRAINT great_international__page_ptr_id_e94f663f_fk_wagtailco FOREIGN KEY (page_ptr_id) REFERENCES public.wagtailcore_page(id) DEFERRABLE INITIALLY DEFERRED; +-- +-- Name: great_international_capitalinvestcontactformsuccesspage great_international__page_ptr_id_f96df5cc_fk_wagtailco; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.great_international_capitalinvestcontactformsuccesspage + ADD CONSTRAINT great_international__page_ptr_id_f96df5cc_fk_wagtailco FOREIGN KEY (page_ptr_id) REFERENCES public.wagtailcore_page(id) DEFERRABLE INITIALLY DEFERRED; + + -- -- Name: great_international_capitalinvestregioncardfieldssummary great_international__page_zh_hans_id_0c11ab1c_fk_great_int; Type: FK CONSTRAINT; Schema: public; Owner: - -- diff --git a/tests/great_international/test_models.py b/tests/great_international/test_models.py index 00eb378c..743367f5 100644 --- a/tests/great_international/test_models.py +++ b/tests/great_international/test_models.py @@ -24,8 +24,6 @@ def test_models_hierarchy(): capital_invest.InternationalCapitalInvestLandingPage, capital_invest.CapitalInvestOpportunityListingPage, capital_invest.CapitalInvestRegionPage, - capital_invest.CapitalInvestContactFormPage, - capital_invest.CapitalInvestContactFormSuccessPage, invest.InvestInternationalHomePage, find_a_supplier.InternationalTradeHomePage ] From b204aab214d8b0e7a86acecaf2551cea8cc54622 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Fri, 9 Aug 2019 09:20:45 +0100 Subject: [PATCH 08/22] Models test --- tests/great_international/test_models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/great_international/test_models.py b/tests/great_international/test_models.py index 743367f5..363a1e68 100644 --- a/tests/great_international/test_models.py +++ b/tests/great_international/test_models.py @@ -71,6 +71,9 @@ def test_models_hierarchy(): assert great_international.InternationalEUExitFormSuccessPage.allowed_parent_page_models() == [ great_international.InternationalEUExitFormPage, ] + assert capital_invest.InternationalCapitalInvestLandingPage.allowed_subpage_models() == [ + capital_invest.CapitalInvestContactFormPage, + ] assert capital_invest.CapitalInvestOpportunityListingPage.allowed_subpage_models() == [ capital_invest.CapitalInvestOpportunityPage, ] From 2d43a500beff4f3802dc92bcf8729ef0761ac174 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Fri, 9 Aug 2019 12:11:18 +0100 Subject: [PATCH 09/22] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 948639f6..89a3da2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Implemented enhancements - No ticket - Add featured industries to Invest home page - CI-321 - About UK landing page +- CI-276 - Added `CapitalInvestContactFormPage` and `CapitalInvestContactFormSuccessPage` ### Fixed Bugs - CI-426 - Added pdf document upload to why choose uk page for ebook section From 96d97201d25613bffa0a7593c3dd7213ae0d2e70 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Fri, 9 Aug 2019 13:50:11 +0100 Subject: [PATCH 10/22] Changed slug for contact --- great_international/models/capital_invest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/great_international/models/capital_invest.py b/great_international/models/capital_invest.py index 411177c1..2587f835 100644 --- a/great_international/models/capital_invest.py +++ b/great_international/models/capital_invest.py @@ -698,7 +698,7 @@ class CapitalInvestContactFormPage( panels.CapitalInvestContactFormPagePanels, WagtailAdminExclusivePageMixin, BaseInternationalPage ): parent_page_types = ['great_international.InternationalCapitalInvestLandingPage'] - slug_identity = 'contact' + slug_identity = 'capital-invest-contact' breadcrumbs_label = models.CharField(max_length=255, blank=True) heading = models.CharField(max_length=255) From 60b650ad428f2d8ce3149f1c22bf79c05cca9f2a Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Fri, 9 Aug 2019 13:53:18 +0100 Subject: [PATCH 11/22] Uses directory constants success slug --- great_international/models/capital_invest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/great_international/models/capital_invest.py b/great_international/models/capital_invest.py index 2587f835..962476c3 100644 --- a/great_international/models/capital_invest.py +++ b/great_international/models/capital_invest.py @@ -14,6 +14,7 @@ from great_international.models.base import BaseInternationalPage import great_international.panels.capital_invest as panels +from directory_constants import slugs class RegionCardField(models.Model): @@ -716,7 +717,7 @@ class CapitalInvestContactFormSuccessPage( panels.CapitalInvestContactFormSuccessPagePanels, WagtailAdminExclusivePageMixin, BaseInternationalPage ): parent_page_types = ['great_international.CapitalInvestContactFormPage'] - slug_identity = 'success' + slug_identity = slugs.FORM_SUCCESS_SLUG large_text = models.CharField(max_length=255) small_text = MarkdownField(blank=True) From 8ac7060bc85fb35d6c246eab591df65da4f84b0e Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Fri, 9 Aug 2019 13:54:35 +0100 Subject: [PATCH 12/22] Added cache subscribers --- great_international/cache.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/great_international/cache.py b/great_international/cache.py index 114e7c63..71b5044c 100644 --- a/great_international/cache.py +++ b/great_international/cache.py @@ -245,11 +245,16 @@ class CapitalInvestContactFormPageSubscriber( AbstractDatabaseCacheSubscriber ): model = capital_invest.CapitalInvestContactFormPage - subscriptions = [] + subscriptions = [ + capital_invest.InternationalCapitalInvestLandingPage + ] class CapitalInvestContactFormSuccessPageSubscriber( AbstractDatabaseCacheSubscriber ): model = capital_invest.CapitalInvestContactFormSuccessPage - subscriptions = [] + subscriptions = [ + capital_invest.InternationalCapitalInvestLandingPage, + capital_invest.CapitalInvestContactFormPage + ] From 9935b084f6fb3886d3cbe63d04b7141bdb2e2282 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Fri, 9 Aug 2019 17:26:12 +0100 Subject: [PATCH 13/22] changed slug back to contact --- great_international/models/capital_invest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/great_international/models/capital_invest.py b/great_international/models/capital_invest.py index 962476c3..38f2b2e7 100644 --- a/great_international/models/capital_invest.py +++ b/great_international/models/capital_invest.py @@ -699,7 +699,7 @@ class CapitalInvestContactFormPage( panels.CapitalInvestContactFormPagePanels, WagtailAdminExclusivePageMixin, BaseInternationalPage ): parent_page_types = ['great_international.InternationalCapitalInvestLandingPage'] - slug_identity = 'capital-invest-contact' + slug_identity = 'contact' breadcrumbs_label = models.CharField(max_length=255, blank=True) heading = models.CharField(max_length=255) From 1257139bf7e3675b8211e97ff9330e8ed27d5426 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Fri, 9 Aug 2019 17:28:06 +0100 Subject: [PATCH 14/22] Using directory constants slug --- great_international/models/capital_invest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/great_international/models/capital_invest.py b/great_international/models/capital_invest.py index 38f2b2e7..b39e94e9 100644 --- a/great_international/models/capital_invest.py +++ b/great_international/models/capital_invest.py @@ -699,7 +699,7 @@ class CapitalInvestContactFormPage( panels.CapitalInvestContactFormPagePanels, WagtailAdminExclusivePageMixin, BaseInternationalPage ): parent_page_types = ['great_international.InternationalCapitalInvestLandingPage'] - slug_identity = 'contact' + slug_identity = slugs.CONTACT_FORM_SLUG breadcrumbs_label = models.CharField(max_length=255, blank=True) heading = models.CharField(max_length=255) From 55dd25f605cefb8a5ec0810aa8fcb3ca5224aead Mon Sep 17 00:00:00 2001 From: Alessandro De Noia Date: Mon, 12 Aug 2019 11:18:58 +0100 Subject: [PATCH 15/22] Add article pages as child pages of international sectors --- great_international/models/great_international.py | 4 +++- great_international/serializers.py | 8 ++++++++ tests/great_international/test_models.py | 1 + tests/great_international/test_views.py | 11 +++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/great_international/models/great_international.py b/great_international/models/great_international.py index 320c6841..03ce455c 100644 --- a/great_international/models/great_international.py +++ b/great_international/models/great_international.py @@ -257,7 +257,8 @@ class Meta: @classmethod def allowed_subpage_models(cls): return [ - InternationalSubSectorPage + InternationalSubSectorPage, + InternationalArticlePage ] @@ -784,6 +785,7 @@ class InternationalArticlePage(panels.InternationalArticlePagePanels, BaseIntern 'great_international.InternationalCampaignPage', 'great_international.InternationalCuratedTopicLandingPage', 'great_international.InternationalGuideLandingPage', + 'great_international.InternationalSectorPage' ] subpage_types = [] diff --git a/great_international/serializers.py b/great_international/serializers.py index 22f7e212..2fa49e38 100644 --- a/great_international/serializers.py +++ b/great_international/serializers.py @@ -657,6 +657,7 @@ class InternationalSectorPageSerializer( ChildPagesSerializerHelper ): child_sub_sectors = serializers.SerializerMethodField() + child_sub_articles = serializers.SerializerMethodField() def get_child_sub_sectors(self, obj): return self.get_child_pages_data_for( @@ -665,6 +666,13 @@ def get_child_sub_sectors(self, obj): MinimalPageSerializer ) + def get_child_sub_articles(self, obj): + return self.get_child_pages_data_for( + obj, + InternationalArticlePage, + RelatedArticlePageSerializer + ) + class InternationalArticlePageSerializer(PageWithRelatedPagesSerializer): article_title = serializers.CharField() diff --git a/tests/great_international/test_models.py b/tests/great_international/test_models.py index 16ddd3e6..2308d2e5 100644 --- a/tests/great_international/test_models.py +++ b/tests/great_international/test_models.py @@ -76,6 +76,7 @@ def test_models_hierarchy(): ] assert great_international.InternationalSectorPage.allowed_subpage_models() == [ great_international.InternationalSubSectorPage, + great_international.InternationalArticlePage ] assert great_international.AboutDitLandingPage.allowed_subpage_models() == [ great_international.AboutDitServicesPage diff --git a/tests/great_international/test_views.py b/tests/great_international/test_views.py index bc13e253..c5ec3143 100644 --- a/tests/great_international/test_views.py +++ b/tests/great_international/test_views.py @@ -314,3 +314,14 @@ def test_international_trade_home_page_exposes_industries( assert response.status_code == 200 assert len(response.json()['industries']) == 1 assert response.json()['industries'][0]['meta']['pk'] == industry.pk + + +def test_sector_page_exposes_articles_child_sub_pages(admin_client, international_root_page): + sector_page = factories.InternationalSectorPageFactory(parent=international_root_page, slug='sector-one') + article_page = factories.InternationalArticlePageFactory(parent=sector_page) + article_page2 = factories.InternationalArticlePageFactory(parent=sector_page) + url = reverse('api:api:pages:detail', kwargs={'pk': sector_page.pk}) + response = admin_client.get(url) + + assert response.status_code == 200 + assert len(response.json()['child_sub_articles']) == 2 From a4b008b746aa3624b4f2da88494e7dbc8762e92d Mon Sep 17 00:00:00 2001 From: Alessandro De Noia Date: Mon, 12 Aug 2019 11:42:49 +0100 Subject: [PATCH 16/22] Placate flake8 --- tests/great_international/test_views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/great_international/test_views.py b/tests/great_international/test_views.py index 11e8eafb..d903bb8c 100644 --- a/tests/great_international/test_views.py +++ b/tests/great_international/test_views.py @@ -311,8 +311,8 @@ def test_international_trade_home_page_exposes_industries( def test_sector_page_exposes_articles_child_sub_pages(admin_client, international_root_page): sector_page = factories.InternationalSectorPageFactory(parent=international_root_page, slug='sector-one') - article_page = factories.InternationalArticlePageFactory(parent=sector_page) - article_page2 = factories.InternationalArticlePageFactory(parent=sector_page) + factories.InternationalArticlePageFactory(parent=sector_page) + factories.InternationalArticlePageFactory(parent=sector_page) url = reverse('api:api:pages:detail', kwargs={'pk': sector_page.pk}) response = admin_client.get(url) From 53b94bf00eb09b21d94252943c1b0e5cb54af246 Mon Sep 17 00:00:00 2001 From: Alessandro De Noia Date: Mon, 12 Aug 2019 11:44:44 +0100 Subject: [PATCH 17/22] add cache subscription --- great_international/cache.py | 4 +++- great_international/serializers.py | 4 ++-- tests/great_international/test_views.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/great_international/cache.py b/great_international/cache.py index 1a2bd147..4eeabe54 100644 --- a/great_international/cache.py +++ b/great_international/cache.py @@ -48,7 +48,9 @@ class InternationalHomePageOldSubscriber(AbstractDatabaseCacheSubscriber): class InternationalArticlePageSubscriber(AbstractDatabaseCacheSubscriber): model = great_international.InternationalArticlePage - subscriptions = [] + subscriptions = [ + great_international.InternationalSectorPage + ] class InternationalCampaignPageSubscriber(AbstractDatabaseCacheSubscriber): diff --git a/great_international/serializers.py b/great_international/serializers.py index 685fd8ce..5533663f 100644 --- a/great_international/serializers.py +++ b/great_international/serializers.py @@ -657,7 +657,7 @@ class InternationalSectorPageSerializer( ChildPagesSerializerHelper ): child_sub_sectors = serializers.SerializerMethodField() - child_sub_articles = serializers.SerializerMethodField() + child_articles = serializers.SerializerMethodField() def get_child_sub_sectors(self, obj): return self.get_child_pages_data_for( @@ -666,7 +666,7 @@ def get_child_sub_sectors(self, obj): MinimalPageSerializer ) - def get_child_sub_articles(self, obj): + def get_child_articles(self, obj): return self.get_child_pages_data_for( obj, InternationalArticlePage, diff --git a/tests/great_international/test_views.py b/tests/great_international/test_views.py index d903bb8c..547f4d01 100644 --- a/tests/great_international/test_views.py +++ b/tests/great_international/test_views.py @@ -317,4 +317,4 @@ def test_sector_page_exposes_articles_child_sub_pages(admin_client, internationa response = admin_client.get(url) assert response.status_code == 200 - assert len(response.json()['child_sub_articles']) == 2 + assert len(response.json()['child_articles']) == 2 From 7aef844a1b74e22b2002b2ed9ade9c2b8f116c8b Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Tue, 13 Aug 2019 09:54:00 +0100 Subject: [PATCH 18/22] Tree based breadcrumbs serialize breadcrumbs label to be title if label given --- CHANGELOG.md | 1 + core/serializers.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89a3da2a..8604c22f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - No ticket - Add featured industries to Invest home page - CI-321 - About UK landing page - CI-276 - Added `CapitalInvestContactFormPage` and `CapitalInvestContactFormSuccessPage` +- CI-429 - Tree based breadcrumbs can now use `breadcrumbs_label` if available ### Fixed Bugs - CI-426 - Added pdf document upload to why choose uk page for ebook section diff --git a/core/serializers.py b/core/serializers.py index a18caa0d..b972ea9c 100644 --- a/core/serializers.py +++ b/core/serializers.py @@ -10,6 +10,11 @@ class PageTitleAndUrlSerializer(serializers.Serializer): url = serializers.CharField() +class PageBreadcrumbsAndUrlSerializer(serializers.Serializer): + title = serializers.CharField(source='breadcrumbs_label') + url = serializers.CharField() + + class BasePageSerializer(serializers.Serializer): id = serializers.IntegerField() seo_title = serializers.CharField() @@ -27,7 +32,15 @@ def get_tree_based_breadcrumbs(self, instance): breadcrumbs = [ page.specific for page in instance.specific.ancestors_in_app] breadcrumbs.append(instance) - return PageTitleAndUrlSerializer(breadcrumbs, many=True).data + serialized = [] + + for crumb in breadcrumbs: + if hasattr(crumb, 'breadcrumbs_label'): + serialized.append(PageBreadcrumbsAndUrlSerializer(crumb).data) + else: + serialized.append(PageTitleAndUrlSerializer(crumb).data) + + return serialized def get_page_type(self, instance): return instance.__class__.__name__ From 0c5f45b940ba67a57015cf19857f68596ffd8770 Mon Sep 17 00:00:00 2001 From: JessGilbert Date: Tue, 13 Aug 2019 11:16:04 +0100 Subject: [PATCH 19/22] Testing the serializer in english --- tests/core/test_serializers.py | 29 +++++++++++++++++++++++++ tests/great_international/factories.py | 30 ++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/tests/core/test_serializers.py b/tests/core/test_serializers.py index 9837c6c5..26e4df0d 100644 --- a/tests/core/test_serializers.py +++ b/tests/core/test_serializers.py @@ -1,5 +1,8 @@ import pytest from find_a_supplier.serializers import IndustryPageSerializer +from great_international.serializers import CapitalInvestContactFormSuccessPageSerializer +from tests.great_international.factories import CapitalInvestContactFormPageFactory, \ + CapitalInvestContactFormSuccessPageFactory @pytest.mark.django_db @@ -21,3 +24,29 @@ def test_base_page_serializer(page, rf): assert serializer.data['last_published_at'] == page.last_published_at assert serializer.data['title'] == page.title assert serializer.data['page_type'] == 'IndustryPage' + + +@pytest.mark.django_db +def test_tree_based_breadcrumbs_for_base_page_serializer( + rf, international_root_page +): + form_page = CapitalInvestContactFormPageFactory( + slug='contact', + title_en_gb='form-title', + breadcrumbs_label='breadcrumbs', + parent=international_root_page + ) + + success_page = CapitalInvestContactFormSuccessPageFactory( + slug='success', + title_en_gb="success-title", + parent=form_page + ) + + success_serializer = CapitalInvestContactFormSuccessPageSerializer( + instance=success_page, + context={'request': rf.get('/')} + ) + + assert success_serializer.data['tree_based_breadcrumbs'][0]['title'] == 'breadcrumbs' + assert success_serializer.data['tree_based_breadcrumbs'][1]['title'] == 'success-title' diff --git a/tests/great_international/factories.py b/tests/great_international/factories.py index 7b877511..7d31404a 100644 --- a/tests/great_international/factories.py +++ b/tests/great_international/factories.py @@ -738,3 +738,33 @@ class Meta: title_en_gb = factory.Sequence(lambda n: '123-555-{0}'.format(n)) last_published_at = timezone.now() parent = None + + +class CapitalInvestContactFormPageFactory( + wagtail_factories.PageFactory +): + + class Meta: + model = models.capital_invest.CapitalInvestContactFormPage + + heading = factory.fuzzy.FuzzyText(length=50) + intro = factory.fuzzy.FuzzyText(length=50) + cta_text = factory.fuzzy.FuzzyText(length=50) + slug = factory.Sequence(lambda n: '123-555-{0}'.format(n)) + title_en_gb = factory.Sequence(lambda n: '123-555-{0}'.format(n)) + last_published_at = timezone.now() + parent = None + + +class CapitalInvestContactFormSuccessPageFactory( + wagtail_factories.PageFactory +): + + class Meta: + model = models.capital_invest.CapitalInvestContactFormSuccessPage + + large_text = factory.fuzzy.FuzzyText(length=50) + slug = factory.Sequence(lambda n: '123-555-{0}'.format(n)) + title_en_gb = factory.Sequence(lambda n: '123-555-{0}'.format(n)) + last_published_at = timezone.now() + parent = None From dc826a997e0bd1f1a423363ba8e5e7b5f044acd8 Mon Sep 17 00:00:00 2001 From: eadpearce Date: Wed, 14 Aug 2019 10:41:14 +0100 Subject: [PATCH 20/22] Make teaser field optional in international articles --- .../migrations/0067_auto_20190814_0940.py | 58 +++++++++++++++++++ .../models/great_international.py | 1 + 2 files changed, 59 insertions(+) create mode 100644 great_international/migrations/0067_auto_20190814_0940.py diff --git a/great_international/migrations/0067_auto_20190814_0940.py b/great_international/migrations/0067_auto_20190814_0940.py new file mode 100644 index 00000000..48055ce4 --- /dev/null +++ b/great_international/migrations/0067_auto_20190814_0940.py @@ -0,0 +1,58 @@ +# Generated by Django 2.2.3 on 2019-08-14 09:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('great_international', '0066_capitalinvestcontactformpage_capitalinvestcontactformsuccesspage'), + ] + + operations = [ + migrations.AlterField( + model_name='internationalarticlepage', + name='article_teaser', + field=models.TextField(blank=True, help_text='This is a subheading that displays when the article is featured on another page'), + ), + migrations.AlterField( + model_name='internationalarticlepage', + name='article_teaser_ar', + field=models.TextField(blank=True, help_text='This is a subheading that displays when the article is featured on another page', null=True), + ), + migrations.AlterField( + model_name='internationalarticlepage', + name='article_teaser_de', + field=models.TextField(blank=True, help_text='This is a subheading that displays when the article is featured on another page', null=True), + ), + migrations.AlterField( + model_name='internationalarticlepage', + name='article_teaser_en_gb', + field=models.TextField(blank=True, help_text='This is a subheading that displays when the article is featured on another page', null=True), + ), + migrations.AlterField( + model_name='internationalarticlepage', + name='article_teaser_es', + field=models.TextField(blank=True, help_text='This is a subheading that displays when the article is featured on another page', null=True), + ), + migrations.AlterField( + model_name='internationalarticlepage', + name='article_teaser_fr', + field=models.TextField(blank=True, help_text='This is a subheading that displays when the article is featured on another page', null=True), + ), + migrations.AlterField( + model_name='internationalarticlepage', + name='article_teaser_ja', + field=models.TextField(blank=True, help_text='This is a subheading that displays when the article is featured on another page', null=True), + ), + migrations.AlterField( + model_name='internationalarticlepage', + name='article_teaser_pt', + field=models.TextField(blank=True, help_text='This is a subheading that displays when the article is featured on another page', null=True), + ), + migrations.AlterField( + model_name='internationalarticlepage', + name='article_teaser_zh_hans', + field=models.TextField(blank=True, help_text='This is a subheading that displays when the article is featured on another page', null=True), + ), + ] diff --git a/great_international/models/great_international.py b/great_international/models/great_international.py index a7f2f35d..e230e0ae 100644 --- a/great_international/models/great_international.py +++ b/great_international/models/great_international.py @@ -796,6 +796,7 @@ class InternationalArticlePage(panels.InternationalArticlePagePanels, BaseIntern "below the main title on the article page" ) article_teaser = models.TextField( + blank=True, help_text="This is a subheading that displays when the article " "is featured on another page" ) From a1f0c08fd006b402f1225e392ae01afe64eb270b Mon Sep 17 00:00:00 2001 From: eadpearce Date: Wed, 14 Aug 2019 10:41:39 +0100 Subject: [PATCH 21/22] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89a3da2a..38a340f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Pre-release ### Implemented enhancements +- No ticket - Make teaser field optional in international articles - No ticket - Add featured industries to Invest home page - CI-321 - About UK landing page - CI-276 - Added `CapitalInvestContactFormPage` and `CapitalInvestContactFormSuccessPage` From b4ffb6bc6aa06a0bcb5422373112d88b002e20e8 Mon Sep 17 00:00:00 2001 From: eadpearce Date: Wed, 14 Aug 2019 10:43:54 +0100 Subject: [PATCH 22/22] Update db template --- db_template.sql | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/db_template.sql b/db_template.sql index c5f6c0f9..151211f5 100644 --- a/db_template.sql +++ b/db_template.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 10.6 (Ubuntu 10.6-0ubuntu0.18.04.1) --- Dumped by pg_dump version 10.6 (Ubuntu 10.6-0ubuntu0.18.04.1) +-- Dumped from database version 9.6.14 +-- Dumped by pg_dump version 11.3 SET statement_timeout = 0; SET lock_timeout = 0; @@ -12,23 +12,10 @@ SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; +SET xmloption = content; SET client_min_messages = warning; SET row_security = off; --- --- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; - - --- --- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; - - SET default_tablespace = ''; SET default_with_oids = false; @@ -13227,6 +13214,7 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin; 358 great_international 0064_merge_20190808_0928 2019-08-08 10:30:16.542222+01 359 great_international 0065_auto_20190808_1032 2019-08-08 11:37:15.180475+01 360 great_international 0066_capitalinvestcontactformpage_capitalinvestcontactformsuccesspage 2019-08-09 09:15:15.500538+01 +361 great_international 0067_auto_20190814_0940 2019-08-14 10:42:44.256149+01 \. @@ -14326,7 +14314,7 @@ SELECT pg_catalog.setval('public.django_content_type_id_seq', 121, true); -- Name: django_migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: - -- -SELECT pg_catalog.setval('public.django_migrations_id_seq', 360, true); +SELECT pg_catalog.setval('public.django_migrations_id_seq', 361, true); --