Added `image_grid` and `image_text` blocks to Article (#11334)
* Added fields to article page, migration * Updated factory body fields * formatting * `inv format` run
This commit is contained in:
Родитель
7e81e3771b
Коммит
01ee5213cd
|
@ -18,6 +18,8 @@ article_body_streamfield_fields = [
|
|||
"callout",
|
||||
"content",
|
||||
"full_width_image",
|
||||
"image_grid",
|
||||
"image_text",
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,704 @@
|
|||
# Generated by Django 3.2.21 on 2023-10-27 16:38
|
||||
|
||||
import django.core.validators
|
||||
import wagtail.blocks
|
||||
import wagtail.contrib.table_block.blocks
|
||||
import wagtail.documents.blocks
|
||||
import wagtail.embeds.blocks
|
||||
import wagtail.fields
|
||||
import wagtail.images.blocks
|
||||
from django.db import migrations
|
||||
|
||||
import networkapi.wagtailpages.pagemodels.customblocks.articles
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("wagtailpages", "0109_delete_featureflags"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="articlepage",
|
||||
name="body",
|
||||
field=wagtail.fields.StreamField(
|
||||
[
|
||||
(
|
||||
"accordion",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"accordion_items",
|
||||
wagtail.blocks.ListBlock(
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"title",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Heading for the Accordion Item"
|
||||
),
|
||||
),
|
||||
(
|
||||
"content",
|
||||
wagtail.blocks.StreamBlock(
|
||||
[
|
||||
(
|
||||
"rich_text",
|
||||
wagtail.blocks.RichTextBlock(
|
||||
blank=True,
|
||||
features=[
|
||||
"bold",
|
||||
"italic",
|
||||
"link",
|
||||
"ul",
|
||||
"ol",
|
||||
"document-link",
|
||||
],
|
||||
),
|
||||
),
|
||||
(
|
||||
"datawrapper",
|
||||
wagtail.embeds.blocks.EmbedBlock(
|
||||
help_text='Enter the "visualization only" link of the Datawrapper chart. It looks something like this: https://datawrapper.dwcdn.net/KwSKp/1/',
|
||||
icon="image",
|
||||
template="wagtailpages/blocks/datawrapper_block.html",
|
||||
),
|
||||
),
|
||||
(
|
||||
"image",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"image",
|
||||
wagtail.images.blocks.ImageChooserBlock(),
|
||||
),
|
||||
(
|
||||
"altText",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Image description (for screen readers).",
|
||||
required=True,
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"video",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"url",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="For YouTube: go to your YouTube video and click “Share,” then “Embed,” and then copy and paste the provided URL only. For example: https://www.youtube.com/embed/3FIVXBawyQw For Vimeo: follow similar steps to grab the embed URL. For example: https://player.vimeo.com/video/9004979",
|
||||
label="Embed URL",
|
||||
),
|
||||
),
|
||||
(
|
||||
"caption",
|
||||
wagtail.blocks.CharBlock(required=False),
|
||||
),
|
||||
(
|
||||
"captionURL",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Optional URL for caption to link to.",
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"video_width",
|
||||
wagtail.blocks.ChoiceBlock(
|
||||
choices=[
|
||||
("normal", "Normal"),
|
||||
("wide", "Wide"),
|
||||
("full_width", "Full Width"),
|
||||
],
|
||||
help_text="Wide videos are col-12, Full-Width videos reach both ends of the screen.",
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"airtable",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"url",
|
||||
wagtail.blocks.URLBlock(
|
||||
help_text="Copied from the Airtable embed code. The word 'embed' will be in the url"
|
||||
),
|
||||
),
|
||||
(
|
||||
"height",
|
||||
wagtail.blocks.IntegerBlock(
|
||||
default=533,
|
||||
help_text="The pixel height on desktop view, usually copied from the Airtable embed code",
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"datawrapper",
|
||||
wagtail.embeds.blocks.EmbedBlock(
|
||||
help_text='Enter the "visualization only" link of the Datawrapper chart. It looks something like this: https://datawrapper.dwcdn.net/KwSKp/1/',
|
||||
icon="image",
|
||||
template="wagtailpages/blocks/datawrapper_block.html",
|
||||
),
|
||||
),
|
||||
(
|
||||
"callout",
|
||||
wagtail.blocks.RichTextBlock(
|
||||
features=["bold", "italic", "link", "h2", "h3", "h4", "ul", "ol"],
|
||||
template="wagtailpages/blocks/article_blockquote_block.html",
|
||||
),
|
||||
),
|
||||
(
|
||||
"card_grid",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"cards",
|
||||
wagtail.blocks.ListBlock(
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
("image", wagtail.images.blocks.ImageChooserBlock()),
|
||||
(
|
||||
"alt_text",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Alt text for card's image.", required=False
|
||||
),
|
||||
),
|
||||
("title", wagtail.blocks.CharBlock(help_text="Heading for the card.")),
|
||||
("body", wagtail.blocks.TextBlock(help_text="Body text of the card.")),
|
||||
(
|
||||
"link_url",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Optional URL that this card should link out to. (Note: If left blank, link will not render.) ",
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"link_label",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Optional Label for the URL link above. (Note: If left blank, link will not render.) ",
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
help_text="Please use a minimum of 2 cards.",
|
||||
),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"content",
|
||||
networkapi.wagtailpages.pagemodels.customblocks.articles.ArticleRichText(
|
||||
features=[
|
||||
"bold",
|
||||
"italic",
|
||||
"link",
|
||||
"h2",
|
||||
"h3",
|
||||
"h4",
|
||||
"h5",
|
||||
"ol",
|
||||
"ul",
|
||||
"hr",
|
||||
"document-link",
|
||||
"large",
|
||||
"image",
|
||||
"footnotes",
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"image",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
("image", wagtail.images.blocks.ImageChooserBlock()),
|
||||
(
|
||||
"caption",
|
||||
wagtail.blocks.RichTextBlock(
|
||||
features=["bold", "italic", "link"], label="Image caption", required=False
|
||||
),
|
||||
),
|
||||
("alt_text", wagtail.blocks.CharBlock(required=False)),
|
||||
(
|
||||
"wide_image",
|
||||
wagtail.blocks.BooleanBlock(
|
||||
default=False,
|
||||
help_text='Checking this will use a wider version of this image, but not full width. For an edge-to-edge image, use the "Wide Image" block.',
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"image_grid",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"grid_items",
|
||||
wagtail.blocks.ListBlock(
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
("image", wagtail.images.blocks.ImageChooserBlock()),
|
||||
(
|
||||
"alt_text",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Alt text for this image.", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"caption",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Please remember to properly attribute any images we use.",
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"url",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Optional URL that this figure should link out to.",
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"square_image",
|
||||
wagtail.blocks.BooleanBlock(
|
||||
default=True,
|
||||
help_text="If left checked, the image will be cropped to be square.",
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"image_text",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
("image", wagtail.images.blocks.ImageChooserBlock()),
|
||||
(
|
||||
"altText",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Image description (for screen readers).", required=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"text",
|
||||
wagtail.blocks.RichTextBlock(
|
||||
features=[
|
||||
"bold",
|
||||
"italic",
|
||||
"link",
|
||||
"h2",
|
||||
"h3",
|
||||
"h4",
|
||||
"h5",
|
||||
"ol",
|
||||
"ul",
|
||||
"hr",
|
||||
"document-link",
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"url",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Optional URL that this image should link out to.", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"top_divider",
|
||||
wagtail.blocks.BooleanBlock(
|
||||
help_text="Optional divider above content block.", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"bottom_divider",
|
||||
wagtail.blocks.BooleanBlock(
|
||||
help_text="Optional divider below content block.", required=False
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"double_image",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
("image_1", wagtail.images.blocks.ImageChooserBlock()),
|
||||
(
|
||||
"image_1_caption",
|
||||
wagtail.blocks.RichTextBlock(
|
||||
features=["bold", "italic", "link"], label="Image caption", required=False
|
||||
),
|
||||
),
|
||||
("image_2", wagtail.images.blocks.ImageChooserBlock()),
|
||||
(
|
||||
"image_2_caption",
|
||||
wagtail.blocks.RichTextBlock(
|
||||
features=["bold", "italic", "link"], label="Image caption", required=False
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"full_width_image",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
("image", wagtail.images.blocks.ImageChooserBlock()),
|
||||
(
|
||||
"image_height",
|
||||
wagtail.blocks.IntegerBlock(
|
||||
default=410,
|
||||
help_text="A custom height for this image. The image will be 1400px wide by this height. Note: This may cause images to look pixelated. If the browser is wider than 1400px the height will scale vertically while the width scales horizontally",
|
||||
),
|
||||
),
|
||||
(
|
||||
"caption",
|
||||
wagtail.blocks.RichTextBlock(
|
||||
features=["bold", "italic", "link"], label="Image caption", required=False
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"iframe",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"url",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Please note that only URLs from allow-listed domains will work."
|
||||
),
|
||||
),
|
||||
(
|
||||
"height",
|
||||
wagtail.blocks.IntegerBlock(
|
||||
help_text="Optional integer pixel value for custom iFrame height",
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
("caption", wagtail.blocks.CharBlock(required=False)),
|
||||
(
|
||||
"captionURL",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Optional URL that this caption should link out to.", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"iframe_width",
|
||||
wagtail.blocks.ChoiceBlock(
|
||||
choices=[("normal", "Normal"), ("wide", "Wide"), ("full_width", "Full Width")],
|
||||
help_text="Wide iframes are col-12, Full-Width iframes reach both ends of the screen",
|
||||
),
|
||||
),
|
||||
(
|
||||
"disable_scroll",
|
||||
wagtail.blocks.BooleanBlock(
|
||||
default=False,
|
||||
help_text='Checking this will add "scrolling=no" to the iframe. Use this if your iframe is rendering an unnecessary scroll bar or whitespace below it.',
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"linkbutton",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
("label", wagtail.blocks.CharBlock()),
|
||||
("URL", wagtail.blocks.CharBlock()),
|
||||
(
|
||||
"styling",
|
||||
wagtail.blocks.ChoiceBlock(
|
||||
choices=[
|
||||
("btn-primary", "Primary button"),
|
||||
("btn-secondary", "Secondary button"),
|
||||
]
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"single_quote",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
("quote", wagtail.blocks.RichTextBlock(features=["bold"])),
|
||||
("attribution", wagtail.blocks.CharBlock(required=False)),
|
||||
(
|
||||
"attribution_info",
|
||||
wagtail.blocks.RichTextBlock(features=["bold", "link", "large"], required=False),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"slider",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"title",
|
||||
wagtail.blocks.CharBlock(help_text="Heading for the slider.", required=False),
|
||||
),
|
||||
(
|
||||
"slides",
|
||||
wagtail.blocks.StreamBlock(
|
||||
[
|
||||
(
|
||||
"slide",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"title",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Heading of the card.", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"image",
|
||||
wagtail.images.blocks.ImageChooserBlock(
|
||||
help_text="The image associated with this event."
|
||||
),
|
||||
),
|
||||
(
|
||||
"caption",
|
||||
wagtail.blocks.TextBlock(
|
||||
help_text="Caption for slider image", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"body",
|
||||
wagtail.blocks.RichTextBlock(
|
||||
blank=True,
|
||||
features=["bold", "italic", "link", "large"],
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"buttons",
|
||||
wagtail.blocks.StreamBlock(
|
||||
[
|
||||
(
|
||||
"internal",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"label",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Label for this link."
|
||||
),
|
||||
),
|
||||
(
|
||||
"link",
|
||||
wagtail.blocks.PageChooserBlock(
|
||||
help_text="Page that this should link out to."
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"external",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"label",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Label for this link."
|
||||
),
|
||||
),
|
||||
(
|
||||
"link",
|
||||
wagtail.blocks.URLBlock(
|
||||
help_text="URL that this should link out to."
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"document",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"label",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Label for this link."
|
||||
),
|
||||
),
|
||||
(
|
||||
"document",
|
||||
wagtail.documents.blocks.DocumentChooserBlock(
|
||||
help_text="Document that this should link out to."
|
||||
),
|
||||
),
|
||||
],
|
||||
help_text='An iCal document can be attached here for an "Add to Calendar" button.',
|
||||
),
|
||||
),
|
||||
],
|
||||
help_text="A list of buttons that will appear at the bottom of the card.",
|
||||
max_num=2,
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
)
|
||||
],
|
||||
help_text="A list of slides.",
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"table",
|
||||
wagtail.contrib.table_block.blocks.TableBlock(
|
||||
template="wagtailpages/blocks/article_table_block.html"
|
||||
),
|
||||
),
|
||||
(
|
||||
"video",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"url",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="For YouTube: go to your YouTube video and click “Share,” then “Embed,” and then copy and paste the provided URL only. For example: https://www.youtube.com/embed/3FIVXBawyQw For Vimeo: follow similar steps to grab the embed URL. For example: https://player.vimeo.com/video/9004979",
|
||||
label="Embed URL",
|
||||
),
|
||||
),
|
||||
("caption", wagtail.blocks.CharBlock(required=False)),
|
||||
(
|
||||
"captionURL",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="Optional URL for caption to link to.", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"video_width",
|
||||
wagtail.blocks.ChoiceBlock(
|
||||
choices=[("normal", "Normal"), ("wide", "Wide"), ("full_width", "Full Width")],
|
||||
help_text="Wide videos are col-12, Full-Width videos reach both ends of the screen.",
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
(
|
||||
"advanced_table",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"header",
|
||||
wagtail.blocks.BooleanBlock(
|
||||
help_text="Display the first row as a header.", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"column",
|
||||
wagtail.blocks.BooleanBlock(
|
||||
help_text="Display the first column as a header.", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"caption",
|
||||
wagtail.blocks.CharBlock(
|
||||
help_text="A heading that identifies the overall topic of the table, and is useful for screen reader users",
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"wide",
|
||||
wagtail.blocks.BooleanBlock(
|
||||
default=True,
|
||||
help_text="If this is checked, the table will render wider than the other page body content.",
|
||||
required=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"table",
|
||||
wagtail.blocks.StreamBlock(
|
||||
[
|
||||
(
|
||||
"row",
|
||||
wagtail.blocks.StreamBlock(
|
||||
[
|
||||
(
|
||||
"cell",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
(
|
||||
"centered_text",
|
||||
wagtail.blocks.BooleanBlock(required=False),
|
||||
),
|
||||
(
|
||||
"column_width",
|
||||
wagtail.blocks.IntegerBlock(
|
||||
default=1,
|
||||
help_text="Enter the number of extra cell columns you want to merge together. Merging a cell column will expand a cell to the right. To merge two cells together, set the column width to 2. For 3, set 3. Default is 1. Min 1. Max 20.",
|
||||
validators=[
|
||||
django.core.validators.MaxValueValidator(
|
||||
20
|
||||
),
|
||||
django.core.validators.MinValueValidator(
|
||||
1
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
(
|
||||
"content",
|
||||
wagtail.blocks.RichTextBlock(
|
||||
features=[
|
||||
"bold",
|
||||
"italic",
|
||||
"link",
|
||||
"ul",
|
||||
"ol",
|
||||
]
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
],
|
||||
use_json_field=True,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -27,6 +27,8 @@ article_fields = [
|
|||
),
|
||||
),
|
||||
("image", customblocks.ArticleImageBlock()),
|
||||
("image_grid", customblocks.ImageGridBlock()),
|
||||
("image_text", customblocks.ImageTextBlock()),
|
||||
("double_image", customblocks.ArticleDoubleImageBlock()),
|
||||
("full_width_image", customblocks.ArticleFullWidthImageBlock()),
|
||||
("iframe", customblocks.iFrameBlock()),
|
||||
|
|
Загрузка…
Ссылка в новой задаче