Skip to content

Commit

Permalink
Merge pull request #605 from uktrade/develop
Browse files Browse the repository at this point in the history
Staging release
  • Loading branch information
sdonk authored Aug 14, 2019
2 parents 5cb4d86 + e20b8fb commit e752ee7
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
## 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`
- 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
Expand Down
15 changes: 14 additions & 1 deletion core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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__
Expand Down
22 changes: 5 additions & 17 deletions db_template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
\.


Expand Down Expand Up @@ -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);


--
Expand Down
58 changes: 58 additions & 0 deletions great_international/migrations/0067_auto_20190814_0940.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
1 change: 1 addition & 0 deletions great_international/models/great_international.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
29 changes: 29 additions & 0 deletions tests/core/test_serializers.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'
30 changes: 30 additions & 0 deletions tests/great_international/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e752ee7

Please sign in to comment.