From 0002173554ac19e90c26ca727292f05bfa7a926e Mon Sep 17 00:00:00 2001 From: john carroll Date: Mon, 28 Oct 2019 00:54:12 -0400 Subject: [PATCH 1/6] ExamplePage model, template, and migration --- fec/home/migrations/0106_examplepage.py | 36 ++++++++++++++++ fec/home/models.py | 38 +++++++++++++++++ fec/home/templates/home/example_page.html | 52 +++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 fec/home/migrations/0106_examplepage.py create mode 100644 fec/home/templates/home/example_page.html diff --git a/fec/home/migrations/0106_examplepage.py b/fec/home/migrations/0106_examplepage.py new file mode 100644 index 0000000000..421a6fbe56 --- /dev/null +++ b/fec/home/migrations/0106_examplepage.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.23 on 2019-10-28 04:00 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0040_page_draft_title'), + ('wagtailimages', '0021_image_file_hash'), + ('home', '0105_auto_20191003_0006'), + ] + + operations = [ + migrations.CreateModel( + name='ExamplePage', + 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')), + ('pre_title', models.CharField(blank=True, choices=[('how', 'How to report'), ('scenario', 'Example scenario'), ('example', 'Example')], max_length=255, null=True)), + ('body', wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('example_image', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=False)), ('caption', wagtail.core.blocks.RichTextBlock(required=True)), ('image', wagtail.images.blocks.ImageChooserBlock(required=True))])), ('image', wagtail.images.blocks.ImageChooserBlock()), ('reporting_example_cards', wagtail.core.blocks.StructBlock([('card_width', wagtail.core.blocks.ChoiceBlock(choices=[(2, '1/2'), (3, '1/3')], help_text='Control the width of the cards')), ('cards', wagtail.core.blocks.ListBlock(wagtail.core.blocks.PageChooserBlock(), icon='doc-empty'))])), ('internal_button', wagtail.core.blocks.StructBlock([('internal_page', wagtail.core.blocks.PageChooserBlock()), ('text', wagtail.core.blocks.CharBlock())])), ('external_button', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock()), ('text', wagtail.core.blocks.CharBlock())]))], null=True)), + ('related_media_title', models.CharField(blank=True, max_length=255, null=True)), + ('related_media', wagtail.core.fields.StreamField([('continue_learning', wagtail.core.blocks.ListBlock(wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock(required=False)), ('url', wagtail.core.blocks.URLBlock()), ('media_type', wagtail.core.blocks.CharBlock()), ('text', wagtail.core.blocks.CharBlock())]), icon='doc-empty', template='blocks/related-media.html'))], blank=True, null=True)), + ('featured_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/fec/home/models.py b/fec/home/models.py index 74f7496c18..cd041b5a92 100644 --- a/fec/home/models.py +++ b/fec/home/models.py @@ -1170,6 +1170,44 @@ class ReportingExamplePage(Page): def content_section(self): return 'help' +class ExamplePage(Page): + """Page template for disclaimer examples and "example scenario" pages + Always within the Help section""" + featured_image = models.ForeignKey('wagtailimages.Image', blank=True, null=True, + on_delete=models.SET_NULL, related_name='+') + + pre_title = models.CharField(blank=True, null=True, max_length=255, choices=[ + ('how', 'How to report'), + ('scenario', 'Example scenario'), + ('example','Example') + ]) + + body = StreamField([ + ('paragraph', blocks.RichTextBlock()), + ('example_image', ExampleImage()), + ('image', ImageChooserBlock()), + ('reporting_example_cards', ReportingExampleCards()), + ('internal_button', InternalButtonBlock()), + ('external_button', ExternalButtonBlock()), + ], null=True) + + related_media_title = models.CharField(blank=True, null=True, max_length=255) + related_media = StreamField([ + ('continue_learning', blocks.ListBlock(ThumbnailBlock(), icon='doc-empty', template='blocks/related-media.html')), + ], null=True, blank=True) + + content_panels = Page.content_panels + [ + FieldPanel('pre_title'), + ImageChooserPanel('featured_image'), + StreamFieldPanel('body'), + FieldPanel('related_media_title'), + StreamFieldPanel('related_media') + ] + + @property + def content_section(self): + return 'help' + @register_snippet class EmbedTableSnippet(models.Model): title = models.TextField() diff --git a/fec/home/templates/home/example_page.html b/fec/home/templates/home/example_page.html new file mode 100644 index 0000000000..a0b3ab0822 --- /dev/null +++ b/fec/home/templates/home/example_page.html @@ -0,0 +1,52 @@ +{% extends "base.html" %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +{% load staticfiles %} +{% block title %}{{ self.title }}{% endblock %} + + +{% block content %} +{% include 'partials/breadcrumbs.html' with page=self links=self.get_ancestors style='secondary' %} + +
+
+
+ {% if self.featured_image %} + {% image self.featured_image fill-200x200 class="heading__image" %} + {% endif %} +
+ {% if self.pre_title == 'how' %} + How to report + {% elif self.pre_title == 'scenario' %} + Example scenario + {% elif self.pre_title == 'example' %} + Example + {% endif %} +

{{ self.title }}

+
+
+
+ {{ self.body }} +
+ {% if self.related_media %} +
+

{{ self.related_media_title }}

+
+ {% for blocks in self.related_media %} + {% with blocks.value as blocks %} + {% for block in blocks %} +
+ {% image block.image width-200 %} + {{ block.media_type }} +

{{ block.text }}

+
+ {% endfor %} + {% endwith %} + {% endfor %} +
+
+ {% endif %} +
+
+ +{% endblock %} From 0b99470010b5254c9f7d4bf3873176d6e340bcd9 Mon Sep 17 00:00:00 2001 From: john carroll Date: Tue, 29 Oct 2019 00:18:43 -0400 Subject: [PATCH 2/6] remove ExamplePage,add new blocks to ReportingExamplePage, one clean migration --- .../migrations/0106_auto_20191029_0011.py | 28 ++++++++++++++ fec/home/migrations/0106_examplepage.py | 36 ------------------ fec/home/models.py | 38 ++----------------- .../home/reporting_example_page.html | 2 + 4 files changed, 33 insertions(+), 71 deletions(-) create mode 100644 fec/home/migrations/0106_auto_20191029_0011.py delete mode 100644 fec/home/migrations/0106_examplepage.py diff --git a/fec/home/migrations/0106_auto_20191029_0011.py b/fec/home/migrations/0106_auto_20191029_0011.py new file mode 100644 index 0000000000..313a492443 --- /dev/null +++ b/fec/home/migrations/0106_auto_20191029_0011.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.23 on 2019-10-29 04:11 +from __future__ import unicode_literals + +from django.db import migrations, models +import wagtail.core.blocks +import wagtail.core.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0105_auto_20191003_0006'), + ] + + operations = [ + migrations.AlterField( + model_name='reportingexamplepage', + name='body', + field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('example_image', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=False)), ('caption', wagtail.core.blocks.RichTextBlock(required=True)), ('image', wagtail.images.blocks.ImageChooserBlock(required=True))])), ('reporting_example_cards', wagtail.core.blocks.StructBlock([('card_width', wagtail.core.blocks.ChoiceBlock(choices=[(2, '1/2'), (3, '1/3')], help_text='Control the width of the cards')), ('cards', wagtail.core.blocks.ListBlock(wagtail.core.blocks.PageChooserBlock(), icon='doc-empty'))])), ('internal_button', wagtail.core.blocks.StructBlock([('internal_page', wagtail.core.blocks.PageChooserBlock()), ('text', wagtail.core.blocks.CharBlock())])), ('external_button', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock()), ('text', wagtail.core.blocks.CharBlock())])), ('image', wagtail.images.blocks.ImageChooserBlock()), ('html', wagtail.core.blocks.RawHTMLBlock())], null=True), + ), + migrations.AlterField( + model_name='reportingexamplepage', + name='pre_title', + field=models.CharField(blank=True, choices=[('how', 'How to report'), ('scenario', 'Example scenario'), ('example', 'Example')], max_length=255, null=True), + ), + ] diff --git a/fec/home/migrations/0106_examplepage.py b/fec/home/migrations/0106_examplepage.py deleted file mode 100644 index 421a6fbe56..0000000000 --- a/fec/home/migrations/0106_examplepage.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.23 on 2019-10-28 04:00 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion -import wagtail.core.blocks -import wagtail.core.fields -import wagtail.images.blocks - - -class Migration(migrations.Migration): - - dependencies = [ - ('wagtailcore', '0040_page_draft_title'), - ('wagtailimages', '0021_image_file_hash'), - ('home', '0105_auto_20191003_0006'), - ] - - operations = [ - migrations.CreateModel( - name='ExamplePage', - 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')), - ('pre_title', models.CharField(blank=True, choices=[('how', 'How to report'), ('scenario', 'Example scenario'), ('example', 'Example')], max_length=255, null=True)), - ('body', wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('example_image', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=False)), ('caption', wagtail.core.blocks.RichTextBlock(required=True)), ('image', wagtail.images.blocks.ImageChooserBlock(required=True))])), ('image', wagtail.images.blocks.ImageChooserBlock()), ('reporting_example_cards', wagtail.core.blocks.StructBlock([('card_width', wagtail.core.blocks.ChoiceBlock(choices=[(2, '1/2'), (3, '1/3')], help_text='Control the width of the cards')), ('cards', wagtail.core.blocks.ListBlock(wagtail.core.blocks.PageChooserBlock(), icon='doc-empty'))])), ('internal_button', wagtail.core.blocks.StructBlock([('internal_page', wagtail.core.blocks.PageChooserBlock()), ('text', wagtail.core.blocks.CharBlock())])), ('external_button', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock()), ('text', wagtail.core.blocks.CharBlock())]))], null=True)), - ('related_media_title', models.CharField(blank=True, max_length=255, null=True)), - ('related_media', wagtail.core.fields.StreamField([('continue_learning', wagtail.core.blocks.ListBlock(wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock(required=False)), ('url', wagtail.core.blocks.URLBlock()), ('media_type', wagtail.core.blocks.CharBlock()), ('text', wagtail.core.blocks.CharBlock())]), icon='doc-empty', template='blocks/related-media.html'))], blank=True, null=True)), - ('featured_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')), - ], - options={ - 'abstract': False, - }, - bases=('wagtailcore.page',), - ), - ] diff --git a/fec/home/models.py b/fec/home/models.py index cd041b5a92..57dd495f5f 100644 --- a/fec/home/models.py +++ b/fec/home/models.py @@ -1142,40 +1142,6 @@ class ReportingExamplePage(Page): featured_image = models.ForeignKey('wagtailimages.Image', blank=True, null=True, on_delete=models.SET_NULL, related_name='+') - pre_title = models.CharField(blank=True, null=True, max_length=255, choices=[ - ('how', 'How to report'), - ('scenario', 'Example scenario') - ]) - - body = StreamField([ - ('paragraph', blocks.RichTextBlock()), - ('example_image', ExampleImage()), - ('reporting_example_cards', ReportingExampleCards()) - ], null=True) - - related_media_title = models.CharField(blank=True, null=True, max_length=255) - related_media = StreamField([ - ('continue_learning', blocks.ListBlock(ThumbnailBlock(), icon='doc-empty', template='blocks/related-media.html')), - ], null=True, blank=True) - - content_panels = Page.content_panels + [ - FieldPanel('pre_title'), - ImageChooserPanel('featured_image'), - StreamFieldPanel('body'), - FieldPanel('related_media_title'), - StreamFieldPanel('related_media') - ] - - @property - def content_section(self): - return 'help' - -class ExamplePage(Page): - """Page template for disclaimer examples and "example scenario" pages - Always within the Help section""" - featured_image = models.ForeignKey('wagtailimages.Image', blank=True, null=True, - on_delete=models.SET_NULL, related_name='+') - pre_title = models.CharField(blank=True, null=True, max_length=255, choices=[ ('how', 'How to report'), ('scenario', 'Example scenario'), @@ -1185,10 +1151,11 @@ class ExamplePage(Page): body = StreamField([ ('paragraph', blocks.RichTextBlock()), ('example_image', ExampleImage()), - ('image', ImageChooserBlock()), ('reporting_example_cards', ReportingExampleCards()), ('internal_button', InternalButtonBlock()), ('external_button', ExternalButtonBlock()), + ('image', ImageChooserBlock()), + ('html', blocks.RawHTMLBlock()), ], null=True) related_media_title = models.CharField(blank=True, null=True, max_length=255) @@ -1208,6 +1175,7 @@ class ExamplePage(Page): def content_section(self): return 'help' + @register_snippet class EmbedTableSnippet(models.Model): title = models.TextField() diff --git a/fec/home/templates/home/reporting_example_page.html b/fec/home/templates/home/reporting_example_page.html index 03217ab489..a0b3ab0822 100644 --- a/fec/home/templates/home/reporting_example_page.html +++ b/fec/home/templates/home/reporting_example_page.html @@ -19,6 +19,8 @@ How to report {% elif self.pre_title == 'scenario' %} Example scenario + {% elif self.pre_title == 'example' %} + Example {% endif %}

{{ self.title }}

From 1be5c8e99f8b2fff9d13d89d8b391314a32ac381 Mon Sep 17 00:00:00 2001 From: john carroll Date: Fri, 1 Nov 2019 21:56:43 -0400 Subject: [PATCH 3/6] combibe migrations for 1-rename page, 2-add new features into one migration file --- ...uto_20191029_0011.py => 0106_auto_20191101_1759.py} | 10 +++++++--- fec/home/models.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) rename fec/home/migrations/{0106_auto_20191029_0011.py => 0106_auto_20191101_1759.py} (87%) diff --git a/fec/home/migrations/0106_auto_20191029_0011.py b/fec/home/migrations/0106_auto_20191101_1759.py similarity index 87% rename from fec/home/migrations/0106_auto_20191029_0011.py rename to fec/home/migrations/0106_auto_20191101_1759.py index 313a492443..ef0c00ebc7 100644 --- a/fec/home/migrations/0106_auto_20191029_0011.py +++ b/fec/home/migrations/0106_auto_20191101_1759.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.11.23 on 2019-10-29 04:11 +# Generated by Django 1.11.23 on 2019-11-01 21:59 from __future__ import unicode_literals from django.db import migrations, models @@ -15,13 +15,17 @@ class Migration(migrations.Migration): ] operations = [ + migrations.RenameModel( + old_name='ReportingExamplePage', + new_name='ExamplePage', + ), migrations.AlterField( - model_name='reportingexamplepage', + model_name='examplepage', name='body', field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('example_image', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=False)), ('caption', wagtail.core.blocks.RichTextBlock(required=True)), ('image', wagtail.images.blocks.ImageChooserBlock(required=True))])), ('reporting_example_cards', wagtail.core.blocks.StructBlock([('card_width', wagtail.core.blocks.ChoiceBlock(choices=[(2, '1/2'), (3, '1/3')], help_text='Control the width of the cards')), ('cards', wagtail.core.blocks.ListBlock(wagtail.core.blocks.PageChooserBlock(), icon='doc-empty'))])), ('internal_button', wagtail.core.blocks.StructBlock([('internal_page', wagtail.core.blocks.PageChooserBlock()), ('text', wagtail.core.blocks.CharBlock())])), ('external_button', wagtail.core.blocks.StructBlock([('url', wagtail.core.blocks.URLBlock()), ('text', wagtail.core.blocks.CharBlock())])), ('image', wagtail.images.blocks.ImageChooserBlock()), ('html', wagtail.core.blocks.RawHTMLBlock())], null=True), ), migrations.AlterField( - model_name='reportingexamplepage', + model_name='examplepage', name='pre_title', field=models.CharField(blank=True, choices=[('how', 'How to report'), ('scenario', 'Example scenario'), ('example', 'Example')], max_length=255, null=True), ), diff --git a/fec/home/models.py b/fec/home/models.py index 57dd495f5f..af5ea8151b 100644 --- a/fec/home/models.py +++ b/fec/home/models.py @@ -1136,7 +1136,7 @@ def social_image_identifier(self): return 'meeting-page' -class ReportingExamplePage(Page): +class ExamplePage(Page): """Page template for "how to report" and "example scenario" pages Always within the Help section""" featured_image = models.ForeignKey('wagtailimages.Image', blank=True, null=True, @@ -1152,6 +1152,7 @@ class ReportingExamplePage(Page): ('paragraph', blocks.RichTextBlock()), ('example_image', ExampleImage()), ('reporting_example_cards', ReportingExampleCards()), + ('reporting_example_cards', ReportingExampleCards()), ('internal_button', InternalButtonBlock()), ('external_button', ExternalButtonBlock()), ('image', ImageChooserBlock()), @@ -1175,7 +1176,6 @@ class ReportingExamplePage(Page): def content_section(self): return 'help' - @register_snippet class EmbedTableSnippet(models.Model): title = models.TextField() From bcdc9af396bec7f267a4153eef678af069b1d8b2 Mon Sep 17 00:00:00 2001 From: john carroll Date: Fri, 1 Nov 2019 22:13:29 -0400 Subject: [PATCH 4/6] edit tasks.py for feature-space deploy --- tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index 7e7239e8f5..4f42ba8358 100644 --- a/tasks.py +++ b/tasks.py @@ -75,7 +75,7 @@ def _detect_space(repo, branch=None, yes=False): ('stage', lambda _, branch: branch.startswith('release')), ('dev', lambda _, branch: branch == 'develop'), # Uncomment below and adjust branch name to deploy desired feature branch to the feature space - ('feature', lambda _, branch: branch == 'feature/the-branch-name'), + ('feature', lambda _, branch: branch == 'feature/3149-ExamplePage-template-wagtail'), ) From b63542833f46b18c6df389e98d468e00c6b44848 Mon Sep 17 00:00:00 2001 From: john carroll Date: Fri, 1 Nov 2019 22:48:12 -0400 Subject: [PATCH 5/6] delete reporting_example_page html template --- .../home/reporting_example_page.html | 52 ------------------- 1 file changed, 52 deletions(-) delete mode 100644 fec/home/templates/home/reporting_example_page.html diff --git a/fec/home/templates/home/reporting_example_page.html b/fec/home/templates/home/reporting_example_page.html deleted file mode 100644 index a0b3ab0822..0000000000 --- a/fec/home/templates/home/reporting_example_page.html +++ /dev/null @@ -1,52 +0,0 @@ -{% extends "base.html" %} -{% load wagtailcore_tags %} -{% load wagtailimages_tags %} -{% load staticfiles %} -{% block title %}{{ self.title }}{% endblock %} - - -{% block content %} -{% include 'partials/breadcrumbs.html' with page=self links=self.get_ancestors style='secondary' %} - -
-
-
- {% if self.featured_image %} - {% image self.featured_image fill-200x200 class="heading__image" %} - {% endif %} -
- {% if self.pre_title == 'how' %} - How to report - {% elif self.pre_title == 'scenario' %} - Example scenario - {% elif self.pre_title == 'example' %} - Example - {% endif %} -

{{ self.title }}

-
-
-
- {{ self.body }} -
- {% if self.related_media %} -
-

{{ self.related_media_title }}

-
- {% for blocks in self.related_media %} - {% with blocks.value as blocks %} - {% for block in blocks %} -
- {% image block.image width-200 %} - {{ block.media_type }} -

{{ block.text }}

-
- {% endfor %} - {% endwith %} - {% endfor %} -
-
- {% endif %} -
-
- -{% endblock %} From 9da5cb99cca2f61d03da8dfee58d7736a5baebd2 Mon Sep 17 00:00:00 2001 From: john carroll Date: Fri, 1 Nov 2019 22:52:23 -0400 Subject: [PATCH 6/6] comment out tasks for feature-deploy --- tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index 4f42ba8358..fd92d4ffee 100644 --- a/tasks.py +++ b/tasks.py @@ -75,7 +75,7 @@ def _detect_space(repo, branch=None, yes=False): ('stage', lambda _, branch: branch.startswith('release')), ('dev', lambda _, branch: branch == 'develop'), # Uncomment below and adjust branch name to deploy desired feature branch to the feature space - ('feature', lambda _, branch: branch == 'feature/3149-ExamplePage-template-wagtail'), + #('feature', lambda _, branch: branch == 'feature/the-branch-name'), )