diff --git a/opentech/public/funds/migrations/0011_add_awesome_table_block.py b/opentech/public/funds/migrations/0011_add_awesome_table_block.py deleted file mode 100644 index b8d9f5a4b174d6828b5e6c7bcdd5771d3cbf2c0d..0000000000000000000000000000000000000000 --- a/opentech/public/funds/migrations/0011_add_awesome_table_block.py +++ /dev/null @@ -1,30 +0,0 @@ -# Generated by Django 2.0.9 on 2019-03-21 14:04 - -from django.db import migrations -import opentech.public.funds.blocks -import wagtail.core.blocks -import wagtail.core.fields -import wagtail.documents.blocks -import wagtail.embeds.blocks -import wagtail.images.blocks -import wagtail.snippets.blocks - - -class Migration(migrations.Migration): - - dependencies = [ - ('public_funds', '0010_correct_related_page_required'), - ] - - operations = [ - migrations.AlterField( - model_name='baseapplicationpage', - name='body', - field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title', icon='title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('caption', wagtail.core.blocks.CharBlock(required=False))])), ('quote', wagtail.core.blocks.StructBlock([('quote', wagtail.core.blocks.CharBlock(classname='title')), ('attribution', wagtail.core.blocks.CharBlock(required=False)), ('job_title', wagtail.core.blocks.CharBlock(required=False))])), ('embed', wagtail.embeds.blocks.EmbedBlock()), ('call_to_action', wagtail.snippets.blocks.SnippetChooserBlock('utils.CallToActionSnippet', template='blocks/call_to_action_block.html')), ('document', wagtail.core.blocks.StructBlock([('document', wagtail.documents.blocks.DocumentChooserBlock()), ('title', wagtail.core.blocks.CharBlock(required=False))])), ('awesome_table_widget', wagtail.core.blocks.StructBlock([('table_id', wagtail.core.blocks.CharBlock(classname='title', help_text='Please enter only table id from embed code. Table widget code creates automatically.'))])), ('project_list', opentech.public.funds.blocks.ProjectsBlock()), ('reviewer_list', opentech.public.funds.blocks.ReviewersBlock())]), - ), - migrations.AlterField( - model_name='labpage', - name='body', - field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title', icon='title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('caption', wagtail.core.blocks.CharBlock(required=False))])), ('quote', wagtail.core.blocks.StructBlock([('quote', wagtail.core.blocks.CharBlock(classname='title')), ('attribution', wagtail.core.blocks.CharBlock(required=False)), ('job_title', wagtail.core.blocks.CharBlock(required=False))])), ('embed', wagtail.embeds.blocks.EmbedBlock()), ('call_to_action', wagtail.snippets.blocks.SnippetChooserBlock('utils.CallToActionSnippet', template='blocks/call_to_action_block.html')), ('document', wagtail.core.blocks.StructBlock([('document', wagtail.documents.blocks.DocumentChooserBlock()), ('title', wagtail.core.blocks.CharBlock(required=False))])), ('awesome_table_widget', wagtail.core.blocks.StructBlock([('table_id', wagtail.core.blocks.CharBlock(classname='title', help_text='Please enter only table id from embed code. Table widget code creates automatically.'))])), ('reviewer_list', opentech.public.funds.blocks.ReviewersBlock())]), - ), - ] diff --git a/opentech/public/news/blocks.py b/opentech/public/news/blocks.py new file mode 100644 index 0000000000000000000000000000000000000000..9500c249618a5327713b5b606ec02f372d66693f --- /dev/null +++ b/opentech/public/news/blocks.py @@ -0,0 +1,18 @@ +from wagtail.core import blocks + +from opentech.public.utils.blocks import StoryBlock + + +class AwesomeTableWidgetBlock(blocks.StructBlock): + table_id = blocks.CharBlock( + classname="title", + help_text='Please enter only table id from embed code. Table widget code creates automatically.' + ) + + class Meta: + icon = "table" + template = "news/blocks/awesome_table_widget_block.html" + + +class NewsStoryBlock(StoryBlock): + awesome_table_widget = AwesomeTableWidgetBlock() diff --git a/opentech/public/news/migrations/0009_add_awesome_table_block.py b/opentech/public/news/migrations/0009_add_awesome_table_block.py index 3654dd560fe46ae8e9e27af3af306e4cc4538838..7f509d4cdee7373b5569fc370051c2c6b924db87 100644 --- a/opentech/public/news/migrations/0009_add_awesome_table_block.py +++ b/opentech/public/news/migrations/0009_add_awesome_table_block.py @@ -1,4 +1,4 @@ -# Generated by Django 2.0.9 on 2019-03-21 14:04 +# Generated by Django 2.0.9 on 2019-03-21 14:25 from django.db import migrations import wagtail.core.blocks diff --git a/opentech/public/news/models.py b/opentech/public/news/models.py index 7de88054f46f1c19e3af80a191721d017af686fa..c5a9f5d3f31d0c95858f527f1d941e426068d9b2 100644 --- a/opentech/public/news/models.py +++ b/opentech/public/news/models.py @@ -16,7 +16,8 @@ from wagtail.admin.edit_handlers import ( from wagtail.search import index from opentech.public.utils.models import BasePage, RelatedPage -from opentech.public.utils.blocks import StoryBlock + +from .blocks import NewsStoryBlock class NewsType(models.Model): @@ -97,7 +98,7 @@ class NewsPage(BasePage): "news item appears to have been published." ) introduction = models.TextField(blank=True) - body = StreamField(StoryBlock(block_counts={'awesome_table_widget': {'max_num': 1}})) + body = StreamField(NewsStoryBlock(block_counts={'awesome_table_widget': {'max_num': 1}})) search_fields = BasePage.search_fields + [ index.SearchField('introduction'), diff --git a/opentech/templates/blocks/awesome_table_widget_block.html b/opentech/public/news/templates/news/blocks/awesome_table_widget_block.html similarity index 100% rename from opentech/templates/blocks/awesome_table_widget_block.html rename to opentech/public/news/templates/news/blocks/awesome_table_widget_block.html diff --git a/opentech/public/people/migrations/0013_add_awesome_table_block.py b/opentech/public/people/migrations/0013_add_awesome_table_block.py deleted file mode 100644 index 133643f49b3d0706005f38da86d41d7acaf29a28..0000000000000000000000000000000000000000 --- a/opentech/public/people/migrations/0013_add_awesome_table_block.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.0.9 on 2019-03-21 14:04 - -from django.db import migrations -import wagtail.core.blocks -import wagtail.core.fields -import wagtail.documents.blocks -import wagtail.embeds.blocks -import wagtail.images.blocks -import wagtail.snippets.blocks - - -class Migration(migrations.Migration): - - dependencies = [ - ('people', '0012_personindexpage_introduction'), - ] - - operations = [ - migrations.AlterField( - model_name='personpage', - name='biography', - field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title', icon='title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('caption', wagtail.core.blocks.CharBlock(required=False))])), ('quote', wagtail.core.blocks.StructBlock([('quote', wagtail.core.blocks.CharBlock(classname='title')), ('attribution', wagtail.core.blocks.CharBlock(required=False)), ('job_title', wagtail.core.blocks.CharBlock(required=False))])), ('embed', wagtail.embeds.blocks.EmbedBlock()), ('call_to_action', wagtail.snippets.blocks.SnippetChooserBlock('utils.CallToActionSnippet', template='blocks/call_to_action_block.html')), ('document', wagtail.core.blocks.StructBlock([('document', wagtail.documents.blocks.DocumentChooserBlock()), ('title', wagtail.core.blocks.CharBlock(required=False))])), ('awesome_table_widget', wagtail.core.blocks.StructBlock([('table_id', wagtail.core.blocks.CharBlock(classname='title', help_text='Please enter only table id from embed code. Table widget code creates automatically.'))]))], blank=True), - ), - ] diff --git a/opentech/public/projects/migrations/0008_add_awesome_table_block.py b/opentech/public/projects/migrations/0008_add_awesome_table_block.py deleted file mode 100644 index 39ce325f7d1d560b857d627e426377ac1feed5de..0000000000000000000000000000000000000000 --- a/opentech/public/projects/migrations/0008_add_awesome_table_block.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.0.9 on 2019-03-21 14:04 - -from django.db import migrations -import wagtail.core.blocks -import wagtail.core.fields -import wagtail.documents.blocks -import wagtail.embeds.blocks -import wagtail.images.blocks -import wagtail.snippets.blocks - - -class Migration(migrations.Migration): - - dependencies = [ - ('projects', '0007_fix_related_page_required_behaviour'), - ] - - operations = [ - migrations.AlterField( - model_name='projectpage', - name='body', - field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title', icon='title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('caption', wagtail.core.blocks.CharBlock(required=False))])), ('quote', wagtail.core.blocks.StructBlock([('quote', wagtail.core.blocks.CharBlock(classname='title')), ('attribution', wagtail.core.blocks.CharBlock(required=False)), ('job_title', wagtail.core.blocks.CharBlock(required=False))])), ('embed', wagtail.embeds.blocks.EmbedBlock()), ('call_to_action', wagtail.snippets.blocks.SnippetChooserBlock('utils.CallToActionSnippet', template='blocks/call_to_action_block.html')), ('document', wagtail.core.blocks.StructBlock([('document', wagtail.documents.blocks.DocumentChooserBlock()), ('title', wagtail.core.blocks.CharBlock(required=False))])), ('awesome_table_widget', wagtail.core.blocks.StructBlock([('table_id', wagtail.core.blocks.CharBlock(classname='title', help_text='Please enter only table id from embed code. Table widget code creates automatically.'))]))]), - ), - ] diff --git a/opentech/public/standardpages/migrations/0004_add_awesome_table_block.py b/opentech/public/standardpages/migrations/0004_add_awesome_table_block.py deleted file mode 100644 index c80159560a175073a03a5f966c9edfbae6677230..0000000000000000000000000000000000000000 --- a/opentech/public/standardpages/migrations/0004_add_awesome_table_block.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.0.9 on 2019-03-21 14:04 - -from django.db import migrations -import wagtail.core.blocks -import wagtail.core.fields -import wagtail.documents.blocks -import wagtail.embeds.blocks -import wagtail.images.blocks -import wagtail.snippets.blocks - - -class Migration(migrations.Migration): - - dependencies = [ - ('standardpages', '0003_correct_related_page_behaviour'), - ] - - operations = [ - migrations.AlterField( - model_name='informationpage', - name='body', - field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title', icon='title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('caption', wagtail.core.blocks.CharBlock(required=False))])), ('quote', wagtail.core.blocks.StructBlock([('quote', wagtail.core.blocks.CharBlock(classname='title')), ('attribution', wagtail.core.blocks.CharBlock(required=False)), ('job_title', wagtail.core.blocks.CharBlock(required=False))])), ('embed', wagtail.embeds.blocks.EmbedBlock()), ('call_to_action', wagtail.snippets.blocks.SnippetChooserBlock('utils.CallToActionSnippet', template='blocks/call_to_action_block.html')), ('document', wagtail.core.blocks.StructBlock([('document', wagtail.documents.blocks.DocumentChooserBlock()), ('title', wagtail.core.blocks.CharBlock(required=False))])), ('awesome_table_widget', wagtail.core.blocks.StructBlock([('table_id', wagtail.core.blocks.CharBlock(classname='title', help_text='Please enter only table id from embed code. Table widget code creates automatically.'))]))]), - ), - ] diff --git a/opentech/public/utils/blocks.py b/opentech/public/utils/blocks.py index cbce08839322ef2dbe0e47329da40a060016d22b..69409c87fc1ffe0f8c9fe843a1f944c696424c93 100644 --- a/opentech/public/utils/blocks.py +++ b/opentech/public/utils/blocks.py @@ -33,17 +33,6 @@ class QuoteBlock(blocks.StructBlock): template = "blocks/quote_block.html" -class AwesomeTableWidgetBlock(blocks.StructBlock): - table_id = blocks.CharBlock( - classname="title", - help_text='Please enter only table id from embed code. Table widget code creates automatically.' - ) - - class Meta: - icon = "table" - template = "blocks/awesome_table_widget_block.html" - - # Main streamfield block to be inherited by Pages class StoryBlock(blocks.StreamBlock): heading = blocks.CharBlock(classname="full title", icon='title') @@ -56,7 +45,6 @@ class StoryBlock(blocks.StreamBlock): template="blocks/call_to_action_block.html" ) document = DocumentBlock() - awesome_table_widget = AwesomeTableWidgetBlock() class Meta: template = "blocks/stream_block.html"