From 5c507614526a2b1e90cda73a5b2b14063cd7c130 Mon Sep 17 00:00:00 2001 From: richtier Date: Tue, 24 Mar 2020 11:41:21 +0000 Subject: [PATCH 1/8] post deloyment changelog --- CHANGELOG.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a829ef8a..8605aa62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,22 @@ # Changelog ## Pre-release + + +## [2020.03.23](https://github.com/uktrade/directory-cms/releases/tag/2020.03.23) +[Full Changelog](https://github.com/uktrade/directory-cms/compare/2020.03.06...2020.03.23) + +### Implemented enhancements - no ticket - Handle non-serializable page requested via /api/pages// - no ticket - Upgrade bleach to fix vulnerability +- no ticket - return only pks on /api/pages/ +- no ticket - Add caching to /api/pages// ## [2020.03.06](https://github.com/uktrade/directory-cms/releases/tag/2020.03.06) [Full Changelog](https://github.com/uktrade/directory-cms/compare/2020.03.04...2020.03.06) ### Implemented enhancements - CMS-1859 - Simplify caching system -- no ticket - return only pks on /api/pages/ -- no ticket - Add caching to /api/pages// - no ticket - Remove region support ## [2020.03.04](https://github.com/uktrade/directory-cms/releases/tag/2020.03.04) From 1fadcbc737a4dd4f1338a19f03e7b4277687d1bf Mon Sep 17 00:00:00 2001 From: Jayesh Patel Date: Wed, 25 Mar 2020 11:22:05 +0000 Subject: [PATCH 2/8] v3-cipipeline manifest.yml file fix --- manifest.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifest.yml b/manifest.yml index 5428a7c2..96ad19e8 100644 --- a/manifest.yml +++ b/manifest.yml @@ -1,4 +1,5 @@ --- applications: - - buildpack: python_buildpack + - buildpacks: + - python_buildpack timeout: 180 From 4f65212b1c17c1bc8b7448a60163a54de72b4169 Mon Sep 17 00:00:00 2001 From: Jayesh Patel Date: Wed, 25 Mar 2020 11:23:17 +0000 Subject: [PATCH 3/8] v3-cipipeline manifest.yml file fix --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8605aa62..0efc5331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Pre-release +## Hotfix +- No ticket - v3-cipipeline manifest.yml file fix ## [2020.03.23](https://github.com/uktrade/directory-cms/releases/tag/2020.03.23) [Full Changelog](https://github.com/uktrade/directory-cms/compare/2020.03.06...2020.03.23) From 3de6343568425d5a55f982bb1f2d5acc009c268d Mon Sep 17 00:00:00 2001 From: Stefan Dzhestanov Date: Wed, 15 Apr 2020 09:25:40 +0100 Subject: [PATCH 4/8] Adds CTA link field to Capital Investment homepage hero --- .../migrations/0093_auto_20200414_1626.py | 58 +++++++++++++++++++ great_international/models/capital_invest.py | 1 + great_international/panels/capital_invest.py | 3 +- great_international/serializers.py | 1 + great_international/translation.py | 1 + tests/great_international/test_serializers.py | 25 ++++++++ 6 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 great_international/migrations/0093_auto_20200414_1626.py diff --git a/great_international/migrations/0093_auto_20200414_1626.py b/great_international/migrations/0093_auto_20200414_1626.py new file mode 100644 index 00000000..fc735206 --- /dev/null +++ b/great_international/migrations/0093_auto_20200414_1626.py @@ -0,0 +1,58 @@ +# Generated by Django 2.2.10 on 2020-04-14 16:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('great_international', '0092_auto_20200127_1223'), + ] + + operations = [ + migrations.AddField( + model_name='internationalcapitalinvestlandingpage', + name='hero_cta_link', + field=models.CharField(blank=True, max_length=255), + ), + migrations.AddField( + model_name='internationalcapitalinvestlandingpage', + name='hero_cta_link_ar', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='internationalcapitalinvestlandingpage', + name='hero_cta_link_de', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='internationalcapitalinvestlandingpage', + name='hero_cta_link_en_gb', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='internationalcapitalinvestlandingpage', + name='hero_cta_link_es', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='internationalcapitalinvestlandingpage', + name='hero_cta_link_fr', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='internationalcapitalinvestlandingpage', + name='hero_cta_link_ja', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='internationalcapitalinvestlandingpage', + name='hero_cta_link_pt', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='internationalcapitalinvestlandingpage', + name='hero_cta_link_zh_hans', + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/great_international/models/capital_invest.py b/great_international/models/capital_invest.py index e8821253..96421237 100644 --- a/great_international/models/capital_invest.py +++ b/great_international/models/capital_invest.py @@ -149,6 +149,7 @@ class InternationalCapitalInvestLandingPage( ) hero_subtitle = models.CharField(max_length=255, blank=True) hero_cta_text = models.CharField(max_length=255, blank=True) + hero_cta_link = models.CharField(max_length=255, blank=True) featured_description = models.TextField(max_length=255, blank=True) diff --git a/great_international/panels/capital_invest.py b/great_international/panels/capital_invest.py index 138f5ad3..c01b7158 100644 --- a/great_international/panels/capital_invest.py +++ b/great_international/panels/capital_invest.py @@ -21,7 +21,8 @@ class InternationalCapitalInvestLandingPagePanels: FieldPanel('hero_title'), FieldPanel('hero_subheading'), FieldPanel('hero_subtitle'), - FieldPanel('hero_cta_text') + FieldPanel('hero_cta_text'), + FieldPanel('hero_cta_link'), ] ), MultiFieldPanel( diff --git a/great_international/serializers.py b/great_international/serializers.py index febee5a6..651e304f 100644 --- a/great_international/serializers.py +++ b/great_international/serializers.py @@ -1316,6 +1316,7 @@ class InternationalCapitalInvestLandingPageSerializer(BasePageSerializer, HeroSe hero_subheading = serializers.CharField(max_length=255) hero_subtitle = serializers.CharField(max_length=255) hero_cta_text = serializers.CharField(max_length=255) + hero_cta_link = serializers.CharField(max_length=255) reason_to_invest_section_title = serializers.CharField(max_length=255) reason_to_invest_section_intro = serializers.CharField(max_length=255) diff --git a/great_international/translation.py b/great_international/translation.py index c744033c..1a3d15c8 100644 --- a/great_international/translation.py +++ b/great_international/translation.py @@ -415,6 +415,7 @@ class InternationalCapitalInvestLandingPageTranslationOptions( 'hero_subheading', 'hero_subtitle', 'hero_cta_text', + 'hero_cta_link', 'reason_to_invest_section_title', 'reason_to_invest_section_intro', diff --git a/tests/great_international/test_serializers.py b/tests/great_international/test_serializers.py index 5858df9d..60062b42 100644 --- a/tests/great_international/test_serializers.py +++ b/tests/great_international/test_serializers.py @@ -1427,6 +1427,31 @@ def test_new_int_home_page_has_related_capital_invest(rf, international_root_pag assert serializer.data['related_page_invest_capital']['meta']['slug'] == 'capital-invest' +@pytest.mark.django_db +def test_capital_invest_landing_page_has_cta(rf, international_root_page, image): + capital_invest_landing_page = InternationalCapitalInvestLandingPageFactory( + parent=international_root_page, + slug='capital-invest', + hero_title='Hero title', + hero_image=image, + hero_subheading='Hero subheading', + hero_subtitle='Hero subtitle', + hero_cta_text='click here', + hero_cta_link='/hero/cta/link', + ) + + serializer = InternationalCapitalInvestLandingPageSerializer( + instance=capital_invest_landing_page, + context={'request': rf.get('/')}, + ) + + assert serializer.data['hero_title'] == 'Hero title' + assert serializer.data['hero_subheading'] == 'Hero subheading' + assert serializer.data['hero_subtitle'] == 'Hero subtitle' + assert serializer.data['hero_cta_text'] == 'click here' + assert serializer.data['hero_cta_link'] == '/hero/cta/link' + + @pytest.mark.django_db def test_new_int_home_page_has_related_trade(rf, international_root_page, image): trade = InternationalTradeHomePageFactory( From be7977841619058efe91a11386e56daa902700bd Mon Sep 17 00:00:00 2001 From: Stefan Dzhestanov Date: Wed, 15 Apr 2020 09:29:03 +0100 Subject: [PATCH 5/8] Adds entry to the Changelog.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0efc5331..dd62ae97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Pre-release +### Implemented enhancements +- CI-677 - Add CTA link field to Capital Investment homepage hero + ## Hotfix - No ticket - v3-cipipeline manifest.yml file fix From fb6c5c232e839586f8293ba480842f278b3dff98 Mon Sep 17 00:00:00 2001 From: richtier Date: Mon, 20 Apr 2020 12:09:03 +0100 Subject: [PATCH 6/8] Support draft pages in cache --- core/cache.py | 14 ++++++++++++++ core/views.py | 9 ++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/core/cache.py b/core/cache.py index 83ff74a5..899bf602 100644 --- a/core/cache.py +++ b/core/cache.py @@ -129,6 +129,15 @@ def populate_sync(cls, instance): data=serializer.data, lang=language_code, ) + if instance.has_unpublished_changes: + draft_instance = instance.get_latest_nested_revision_as_page() + draft_serializer = serializer_class(instance=draft_instance) + page_cache.set( + page_id=instance.id, + data=draft_serializer.data, + lang=language_code, + draft_version=True + ) @classmethod def delete(cls, instance): @@ -138,6 +147,11 @@ def delete(cls, instance): page_id=instance.id, lang=language_code, ) + page_cache.delete( + page_id=instance.id, + lang=language_code, + draft_version=True + ) class PageIDCache: diff --git a/core/views.py b/core/views.py index b02faa21..4e501a11 100644 --- a/core/views.py +++ b/core/views.py @@ -89,14 +89,13 @@ def detail_view(self, request, **kwargs): # Exit early if there are any issues self.check_parameter_validity() + variation_kwargs = {'lang': translation.get_language()} + if helpers.is_draft_requested(request): - return super().detail_view(request, pk=None) + variation_kwargs['draft_version'] = True # Return a cached response if one is available - cached_data = cache.PageCache.get( - page_id=self.object_id, - lang=translation.get_language(), - ) + cached_data = cache.PageCache.get(page_id=self.object_id, **variation_kwargs) if cached_data: cached_response = helpers.CachedResponse(cached_data) cached_response['etag'] = cached_data.get('etag', None) From 431e0feed27db2be13f85a23ee8d0455b6d61a22 Mon Sep 17 00:00:00 2001 From: richtier Date: Mon, 20 Apr 2020 12:11:50 +0100 Subject: [PATCH 7/8] Fix security vulnerability --- requirements.in | 6 +++--- requirements.txt | 12 ++++++------ requirements_test.txt | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/requirements.in b/requirements.in index 8a37d141..fdd1f87f 100644 --- a/requirements.in +++ b/requirements.in @@ -16,7 +16,7 @@ directory-components==20.0.0 directory-constants==18.6.* django-staff-sso-client==1.0.0 html2text==2018.1.9 -wagtail==2.6.* +wagtail==2.7.* wagtailmedia==0.3.1 pytube==9.2.2 django-filter==2.2.0 @@ -26,13 +26,13 @@ django-celery-beat==2.0.0 kombu==4.6.6 requests==2.21.0 markdown==2.6 -bleach==3.1.1 +bleach==3.1.4 bleach-whitelist==0.0.9 wagtail-modeltranslation==0.10.2 urllib3>=1.24.2<2.0.0 w3lib>=1.19.0<2.0.0 django-admin-ip-restrictor==2.1.0 notifications-python-client==5.3.* -pillow>=6.2.0 # for security fix. check compatibility on next wagtail upgrade +pillow>=6.2.2 # for security fix. check compatibility on next wagtail upgrade num2words==0.5.10 pycountry==19.8.18 diff --git a/requirements.txt b/requirements.txt index f5ed2c6b..feb721bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ attrs==19.3.0 # via jsonschema beautifulsoup4==4.6.0 # via directory-components, wagtail billiard==3.6.1.0 # via celery bleach-whitelist==0.0.9 # via -r requirements.in -bleach==3.1.1 # via -r requirements.in +bleach==3.1.4 # via -r requirements.in boto3==1.6.3 # via -r requirements.in botocore==1.9.23 # via boto3, s3transfer celery[redis]==4.3.0 # via -r requirements.in, django-celery-beat @@ -25,12 +25,12 @@ django-environ==0.4.5 # via -r requirements.in django-filter==2.2.0 # via -r requirements.in django-health-check==3.8.0 # via directory-healthcheck django-ipware==2.1.0 # via django-admin-ip-restrictor -django-modelcluster==4.4 # via wagtail +django-modelcluster==5.0.1 # via wagtail django-modeltranslation==0.14 # via wagtail-modeltranslation django-pglocks==1.0.2 # via -r requirements.in django-redis==4.10.0 # via -r requirements.in django-staff-sso-client==1.0.0 # via -r requirements.in -django-taggit==0.24.0 # via wagtail +django-taggit==1.2.0 # via wagtail django-timezone-field==4.0 # via django-celery-beat django-treebeard==4.3 # via wagtail django==2.2.10 # via -r requirements.in, directory-components, directory-constants, directory-healthcheck, django-admin-ip-restrictor, django-celery-beat, django-filter, django-redis, django-staff-sso-client, django-storages, django-taggit, django-timezone-field, django-treebeard, sigauth, wagtail @@ -57,7 +57,7 @@ more-itertools==8.0.0 # via zipp notifications-python-client==5.3.0 # via -r requirements.in num2words==0.5.10 # via -r requirements.in oauthlib==3.1.0 # via requests-oauthlib -pillow==6.2.1 # via -r requirements.in, wagtail +pillow==6.2.2 # via -r requirements.in, wagtail psycopg2==2.7.3.2 # via -r requirements.in pycountry==19.8.18 # via -r requirements.in pyjwt==1.7.1 # via notifications-python-client @@ -80,11 +80,11 @@ urllib3==1.24.3 # via -r requirements.in, requests, sentry-sdk vine==1.3.0 # via amqp, celery w3lib==1.21.0 # via -r requirements.in wagtail-modeltranslation==0.10.2 # via -r requirements.in -wagtail==2.6.3 # via -r requirements.in, wagtail-modeltranslation, wagtailmedia +wagtail==2.7.2 # via -r requirements.in, wagtail-modeltranslation, wagtailmedia wagtailmedia==0.3.1 # via -r requirements.in webencodings==0.5.1 # via bleach, html5lib whitenoise==4.1.2 # via -r requirements.in -willow==1.1 # via wagtail +willow==1.3 # via wagtail zipp==0.6.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements_test.txt b/requirements_test.txt index f7921bdc..86ca4ab7 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -10,7 +10,7 @@ attrs==18.2.0 # via jsonschema, pytest beautifulsoup4==4.6.0 # via -r requirements_test.in, directory-components, wagtail billiard==3.5.0.5 # via celery bleach-whitelist==0.0.9 # via -r requirements.in -bleach==3.1.1 # via -r requirements.in +bleach==3.1.4 # via -r requirements.in boto3==1.6.3 # via -r requirements.in botocore==1.9.23 # via boto3, s3transfer celery[redis]==4.2.1 # via -r requirements.in, django-celery-beat @@ -30,12 +30,12 @@ django-environ==0.4.5 # via -r requirements.in django-filter==2.2.0 # via -r requirements.in django-health-check==3.8.0 # via directory-healthcheck django-ipware==2.1.0 # via django-admin-ip-restrictor -django-modelcluster==4.3 # via wagtail +django-modelcluster==5.0.1 # via wagtail django-modeltranslation==0.13.1 # via wagtail-modeltranslation django-pglocks==1.0.2 # via -r requirements.in django-redis==4.10.0 # via -r requirements.in django-staff-sso-client==1.0.0 # via -r requirements.in -django-taggit==0.23.0 # via wagtail +django-taggit==1.2.0 # via wagtail django-timezone-field==4.0 # via django-celery-beat django-treebeard==4.3 # via wagtail django==2.2.10 # via -r requirements.in, directory-components, directory-constants, directory-healthcheck, django-admin-ip-restrictor, django-celery-beat, django-debug-toolbar, django-filter, django-redis, django-staff-sso-client, django-storages, django-taggit, django-timezone-field, django-treebeard, sigauth, wagtail @@ -68,7 +68,7 @@ notifications-python-client==5.3.0 # via -r requirements.in num2words==0.5.10 # via -r requirements.in oauthlib==3.0.1 # via requests-oauthlib packaging==18.0 # via pytest, pytest-sugar -pillow==6.2.1 # via -r requirements.in, wagtail +pillow==6.2.2 # via -r requirements.in, wagtail pip-tools==4.3.0 # via -r requirements_test.in pluggy==0.12.0 # via pytest psycopg2==2.7.3.2 # via -r requirements.in @@ -105,12 +105,12 @@ vine==1.1.4 # via amqp w3lib==1.20.0 # via -r requirements.in wagtail-factories==2.0.0 # via -r requirements_test.in wagtail-modeltranslation==0.10.2 # via -r requirements.in -wagtail==2.6.3 # via -r requirements.in, wagtail-factories, wagtail-modeltranslation, wagtailmedia +wagtail==2.7.2 # via -r requirements.in, wagtail-factories, wagtail-modeltranslation, wagtailmedia wagtailmedia==0.3.1 # via -r requirements.in wcwidth==0.1.7 # via pytest webencodings==0.5.1 # via bleach, html5lib whitenoise==4.1.2 # via -r requirements.in -willow==1.1 # via wagtail +willow==1.3 # via wagtail zipp==0.6.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: From 176ed98555cedd47c62553a497f5e4da84b6d342 Mon Sep 17 00:00:00 2001 From: richtier Date: Mon, 20 Apr 2020 16:04:34 +0100 Subject: [PATCH 8/8] Add cache supoort to draft pages --- CHANGELOG.md | 1 + core/cache.py | 5 ++++- core/fields.py | 6 +----- core/views.py | 12 ++++++++++++ requirements.in | 6 +++--- requirements.txt | 12 ++++++------ requirements_test.txt | 12 ++++++------ tests/core/test_cache.py | 19 +++++++++++++------ tests/core/test_fields.py | 4 +--- 9 files changed, 47 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd62ae97..3933d297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Implemented enhancements - CI-677 - Add CTA link field to Capital Investment homepage hero +- no ticket - Add cache supoort to draft pages ## Hotfix - No ticket - v3-cipipeline manifest.yml file fix diff --git a/core/cache.py b/core/cache.py index 899bf602..54e10d81 100644 --- a/core/cache.py +++ b/core/cache.py @@ -131,7 +131,10 @@ def populate_sync(cls, instance): ) if instance.has_unpublished_changes: draft_instance = instance.get_latest_nested_revision_as_page() - draft_serializer = serializer_class(instance=draft_instance) + draft_serializer = serializer_class( + instance=draft_instance, + context={'is_draft': True} + ) page_cache.set( page_id=instance.id, data=draft_serializer.data, diff --git a/core/fields.py b/core/fields.py index 1bac6670..3131f6fa 100644 --- a/core/fields.py +++ b/core/fields.py @@ -15,17 +15,13 @@ def to_representation(self, instance): class MetaDictField(fields.DictField): def get_attribute(self, instance): - if 'request' in self.context: - is_draft = helpers.is_draft_requested(self.context['request']) - else: - is_draft = False return { 'languages': [ (code, label) for (code, label) in settings.LANGUAGES_LOCALIZED if code in instance.specific.translated_languages ], 'url': instance.specific.get_url( - is_draft=is_draft, + is_draft=self.context.get('is_draft', False), language_code=settings.LANGUAGE_CODE, ), 'slug': instance.slug, diff --git a/core/views.py b/core/views.py index 4e501a11..33b63367 100644 --- a/core/views.py +++ b/core/views.py @@ -1,3 +1,5 @@ +from logging import getLogger + from django_filters.rest_framework import DjangoFilterBackend from rest_framework.exceptions import ValidationError from rest_framework.renderers import JSONRenderer @@ -22,6 +24,9 @@ from core.serializer_mapping import MODELS_SERIALIZERS_MAPPING +logger = getLogger(__name__) + + class PageNotSerializableError(NotImplementedError): pass @@ -107,15 +112,22 @@ def detail_view(self, request, **kwargs): # No cached response available response = super().detail_view(request, pk=None) + if response.status_code == 200: # Reuse the already-fetched object to populate the cache cache.CachePopulator.populate_async(self.get_object()) + logger.warn(f'Page cache miss') # No etag is set for this response because creating one is expensive. # If API caching is enabled, one will be added to the cached version # created above. return response + def get_serializer_context(self): + context = super().get_serializer_context() + context['is_draft'] = helpers.is_draft_requested(self.request) + return context + class PagesOptionalDraftAPIEndpoint(APIEndpointBase): def listing_view(self, request): diff --git a/requirements.in b/requirements.in index fdd1f87f..8a37d141 100644 --- a/requirements.in +++ b/requirements.in @@ -16,7 +16,7 @@ directory-components==20.0.0 directory-constants==18.6.* django-staff-sso-client==1.0.0 html2text==2018.1.9 -wagtail==2.7.* +wagtail==2.6.* wagtailmedia==0.3.1 pytube==9.2.2 django-filter==2.2.0 @@ -26,13 +26,13 @@ django-celery-beat==2.0.0 kombu==4.6.6 requests==2.21.0 markdown==2.6 -bleach==3.1.4 +bleach==3.1.1 bleach-whitelist==0.0.9 wagtail-modeltranslation==0.10.2 urllib3>=1.24.2<2.0.0 w3lib>=1.19.0<2.0.0 django-admin-ip-restrictor==2.1.0 notifications-python-client==5.3.* -pillow>=6.2.2 # for security fix. check compatibility on next wagtail upgrade +pillow>=6.2.0 # for security fix. check compatibility on next wagtail upgrade num2words==0.5.10 pycountry==19.8.18 diff --git a/requirements.txt b/requirements.txt index feb721bf..f5ed2c6b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ attrs==19.3.0 # via jsonschema beautifulsoup4==4.6.0 # via directory-components, wagtail billiard==3.6.1.0 # via celery bleach-whitelist==0.0.9 # via -r requirements.in -bleach==3.1.4 # via -r requirements.in +bleach==3.1.1 # via -r requirements.in boto3==1.6.3 # via -r requirements.in botocore==1.9.23 # via boto3, s3transfer celery[redis]==4.3.0 # via -r requirements.in, django-celery-beat @@ -25,12 +25,12 @@ django-environ==0.4.5 # via -r requirements.in django-filter==2.2.0 # via -r requirements.in django-health-check==3.8.0 # via directory-healthcheck django-ipware==2.1.0 # via django-admin-ip-restrictor -django-modelcluster==5.0.1 # via wagtail +django-modelcluster==4.4 # via wagtail django-modeltranslation==0.14 # via wagtail-modeltranslation django-pglocks==1.0.2 # via -r requirements.in django-redis==4.10.0 # via -r requirements.in django-staff-sso-client==1.0.0 # via -r requirements.in -django-taggit==1.2.0 # via wagtail +django-taggit==0.24.0 # via wagtail django-timezone-field==4.0 # via django-celery-beat django-treebeard==4.3 # via wagtail django==2.2.10 # via -r requirements.in, directory-components, directory-constants, directory-healthcheck, django-admin-ip-restrictor, django-celery-beat, django-filter, django-redis, django-staff-sso-client, django-storages, django-taggit, django-timezone-field, django-treebeard, sigauth, wagtail @@ -57,7 +57,7 @@ more-itertools==8.0.0 # via zipp notifications-python-client==5.3.0 # via -r requirements.in num2words==0.5.10 # via -r requirements.in oauthlib==3.1.0 # via requests-oauthlib -pillow==6.2.2 # via -r requirements.in, wagtail +pillow==6.2.1 # via -r requirements.in, wagtail psycopg2==2.7.3.2 # via -r requirements.in pycountry==19.8.18 # via -r requirements.in pyjwt==1.7.1 # via notifications-python-client @@ -80,11 +80,11 @@ urllib3==1.24.3 # via -r requirements.in, requests, sentry-sdk vine==1.3.0 # via amqp, celery w3lib==1.21.0 # via -r requirements.in wagtail-modeltranslation==0.10.2 # via -r requirements.in -wagtail==2.7.2 # via -r requirements.in, wagtail-modeltranslation, wagtailmedia +wagtail==2.6.3 # via -r requirements.in, wagtail-modeltranslation, wagtailmedia wagtailmedia==0.3.1 # via -r requirements.in webencodings==0.5.1 # via bleach, html5lib whitenoise==4.1.2 # via -r requirements.in -willow==1.3 # via wagtail +willow==1.1 # via wagtail zipp==0.6.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements_test.txt b/requirements_test.txt index 86ca4ab7..f7921bdc 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -10,7 +10,7 @@ attrs==18.2.0 # via jsonschema, pytest beautifulsoup4==4.6.0 # via -r requirements_test.in, directory-components, wagtail billiard==3.5.0.5 # via celery bleach-whitelist==0.0.9 # via -r requirements.in -bleach==3.1.4 # via -r requirements.in +bleach==3.1.1 # via -r requirements.in boto3==1.6.3 # via -r requirements.in botocore==1.9.23 # via boto3, s3transfer celery[redis]==4.2.1 # via -r requirements.in, django-celery-beat @@ -30,12 +30,12 @@ django-environ==0.4.5 # via -r requirements.in django-filter==2.2.0 # via -r requirements.in django-health-check==3.8.0 # via directory-healthcheck django-ipware==2.1.0 # via django-admin-ip-restrictor -django-modelcluster==5.0.1 # via wagtail +django-modelcluster==4.3 # via wagtail django-modeltranslation==0.13.1 # via wagtail-modeltranslation django-pglocks==1.0.2 # via -r requirements.in django-redis==4.10.0 # via -r requirements.in django-staff-sso-client==1.0.0 # via -r requirements.in -django-taggit==1.2.0 # via wagtail +django-taggit==0.23.0 # via wagtail django-timezone-field==4.0 # via django-celery-beat django-treebeard==4.3 # via wagtail django==2.2.10 # via -r requirements.in, directory-components, directory-constants, directory-healthcheck, django-admin-ip-restrictor, django-celery-beat, django-debug-toolbar, django-filter, django-redis, django-staff-sso-client, django-storages, django-taggit, django-timezone-field, django-treebeard, sigauth, wagtail @@ -68,7 +68,7 @@ notifications-python-client==5.3.0 # via -r requirements.in num2words==0.5.10 # via -r requirements.in oauthlib==3.0.1 # via requests-oauthlib packaging==18.0 # via pytest, pytest-sugar -pillow==6.2.2 # via -r requirements.in, wagtail +pillow==6.2.1 # via -r requirements.in, wagtail pip-tools==4.3.0 # via -r requirements_test.in pluggy==0.12.0 # via pytest psycopg2==2.7.3.2 # via -r requirements.in @@ -105,12 +105,12 @@ vine==1.1.4 # via amqp w3lib==1.20.0 # via -r requirements.in wagtail-factories==2.0.0 # via -r requirements_test.in wagtail-modeltranslation==0.10.2 # via -r requirements.in -wagtail==2.7.2 # via -r requirements.in, wagtail-factories, wagtail-modeltranslation, wagtailmedia +wagtail==2.6.3 # via -r requirements.in, wagtail-factories, wagtail-modeltranslation, wagtailmedia wagtailmedia==0.3.1 # via -r requirements.in wcwidth==0.1.7 # via pytest webencodings==0.5.1 # via bleach, html5lib whitenoise==4.1.2 # via -r requirements.in -willow==1.3 # via wagtail +willow==1.1 # via wagtail zipp==0.6.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: diff --git a/tests/core/test_cache.py b/tests/core/test_cache.py index 2d29e143..17cea425 100644 --- a/tests/core/test_cache.py +++ b/tests/core/test_cache.py @@ -160,16 +160,23 @@ class TestSubscriber(cache.DatabaseCacheSubscriber): model_classes = [Page] instance = mock.Mock( - id=1, slug='some-slug', service_name='thing', + id=2, slug='some-slug', service_name='thing', translated_languages=['en-gb'] ) TestSubscriber.delete(sender=None, instance=instance) - assert mock_delete.call_count == 1 - assert mock_delete.call_args == mock.call( - page_id=1, - lang='en-gb', - ) + assert mock_delete.call_count == 2 + assert mock_delete.call_args_list == [ + mock.call( + page_id=2, + lang='en-gb', + ), + mock.call( + page_id=2, + lang='en-gb', + draft_version=True, + ) + ] @mock.patch('django.core.cache.cache.set') diff --git a/tests/core/test_fields.py b/tests/core/test_fields.py index 7312b49e..adbd7522 100644 --- a/tests/core/test_fields.py +++ b/tests/core/test_fields.py @@ -5,7 +5,6 @@ from wagtail.core.fields import StreamField from core import fields -from core import permissions from great_international.serializers import InternationalSectorPageSerializer, InternationalArticlePageSerializer from tests.great_international.factories import InternationalSectorPageFactory @@ -103,10 +102,9 @@ def test_meta_field_draft(international_root_page, rf): parent=international_root_page, slug='test-slug', ) - request = rf.get('/', {permissions.DraftTokenPermisison.TOKEN_PARAM: '1'}) serializer = InternationalSectorPageSerializer( instance=sector_page, - context={'request': request} + context={'is_draft': True} ) assert serializer.data['meta']['url'] == sector_page.get_url(is_draft=True)