How to use the wagtail.core.blocks function in wagtail

To help you get started, we’ve selected a few wagtail examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mdn / developer-portal / developerportal / apps / topics / migrations / 0020_topic_featured.py View on Github external
migrations.AddField(
            model_name="topic",
            name="featured",
            field=wagtail.core.fields.StreamField(
                [
                    (
                        "article",
                        wagtail.core.blocks.PageChooserBlock(
                            page_type=["articles.Article"], required=False
                        ),
                    ),
                    (
                        "external_page",
                        wagtail.core.blocks.StructBlock(
                            [
                                ("url", wagtail.core.blocks.URLBlock()),
                                ("title", wagtail.core.blocks.CharBlock()),
                                (
                                    "intro",
                                    wagtail.core.blocks.TextBlock(required=False),
                                ),
                                (
                                    "header_image",
                                    wagtail.images.blocks.ImageChooserBlock(
                                        label="Image"
                                    ),
                                ),
                            ]
                        ),
                    ),
                ],
                blank=True,
github TakwimuAfrica / Takwimu / takwimu / models / dashboard.py View on Github external
# Search index configuration

    search_fields = Page.search_fields + [
        index.SearchField('description')
    ]

    # Editor panels configuration

    content_panels = Page.content_panels + [
        FieldPanel('description'),
        FieldPanel('icon'),
        InlinePanel('data_indicators', label="Data Indicators"),
    ]


class EntityStructBlock(blocks.StructBlock):
    title = blocks.CharBlock()
    name = blocks.CharBlock(required=False)
    image = ImageChooserBlock(required=False)
    description = blocks.RichTextBlock(features=['link'], required=False)

    class Meta:
        icon = 'group'
        template = 'takwimu/_includes/dataview/entity_detail.html'


class DataIndicatorChooserBlock(blocks.ChooserBlock):
    target_model = DataIndicator
    widget = forms.Select

    class Meta:
        icon = 'folder'
github torchbox / wagtail-grapple / grapple / types / streamfield.py View on Github external
blocks.TextBlock: TextBlock,
        blocks.EmailBlock: EmailBlock,
        blocks.IntegerBlock: IntegerBlock,
        blocks.FloatBlock: FloatBlock,
        blocks.DecimalBlock: DecimalBlock,
        blocks.RegexBlock: RegexBlock,
        blocks.URLBlock: URLBlock,
        blocks.BooleanBlock: BooleanBlock,
        blocks.DateBlock: DateBlock,
        blocks.TimeBlock: TimeBlock,
        blocks.DateTimeBlock: DateTimeBlock,
        blocks.RichTextBlock: RichTextBlock,
        blocks.RawHTMLBlock: RawHTMLBlock,
        blocks.BlockQuoteBlock: BlockQuoteBlock,
        blocks.ChoiceBlock: ChoiceBlock,
        blocks.StreamBlock: StreamBlock,
        blocks.StructBlock: StructBlock,
        blocks.StaticBlock: StaticBlock,
        blocks.ListBlock: ListBlock,
        wagtail.embeds.blocks.EmbedBlock: EmbedBlock,
    }
)


def register_streamfield_blocks():
    from .pages import PageInterface
    from .documents import get_document_type
    from .images import get_image_type

    class PageChooserBlock(graphene.ObjectType):
        page = graphene.Field(PageInterface, required=True)
github mdn / developer-portal / developerportal / apps / home / migrations / 0014_auto_20190628_1338.py View on Github external
operations = [
        migrations.AlterField(
            model_name="homepage",
            name="featured",
            field=wagtail.core.fields.StreamField(
                [
                    (
                        "article",
                        wagtail.core.blocks.PageChooserBlock(
                            page_type=["articles.Article"], required=False
                        ),
                    ),
                    (
                        "external_page",
                        wagtail.core.blocks.StructBlock(
                            [
                                ("url", wagtail.core.blocks.URLBlock()),
                                ("title", wagtail.core.blocks.CharBlock()),
                                (
                                    "intro",
                                    wagtail.core.blocks.TextBlock(required=False),
                                ),
                                (
                                    "header_image",
                                    wagtail.images.blocks.ImageChooserBlock(
                                        label="Image"
                                    ),
                                ),
                            ]
                        ),
                    ),
github TakwimuAfrica / Takwimu / takwimu / models / dashboard.py View on Github external
chart_type = blocks.ChoiceBlock(required=True,
                                    choices=[
                                        ('histogram', 'Histogram'),
                                        ('pie', 'Pie Chart'),
                                        ('grouped_column', 'Grouped Column'),
                                    ],
                                    label='Chart Type')
    data_stat_type = blocks.ChoiceBlock(required=True,
                                        choices=[
                                            ('dollar', 'Dollar'),
                                            ('number', 'Number'),
                                            ('percentage', 'Percentage'),
                                            ('scaled-percentage', 'Scaled Percentage'),
                                        ],
                                        label='Stat Type')
    chart_height = blocks.IntegerBlock(required=False,
                                       label='Chart Height',
                                       help_text='Default is 300px')

    data_source_link = blocks.URLBlock(required=False, label='Source URL')

    data_source_title = blocks.CharBlock(required=False, label='Source Title')

    chart_qualifier = blocks.RichTextBlock(
                features=['h5', 'h6', 'ol', 'ul', 'bold', 'italic', 'hr',
                          'link'],
                required=False, label='Chart Qualifier',
                help_text='Chart context e.g. legend, universe, etc.')
                
    description = blocks.TextBlock(
        required=False, label='Description of the data')
github mdn / developer-portal / developerportal / apps / home / migrations / 0028_auto_20190814_1600.py View on Github external
wagtail.core.blocks.PageChooserBlock(
                            page_type=[
                                "articles.Article",
                                "externalcontent.ExternalArticle",
                            ]
                        ),
                    ),
                    (
                        "external_page",
                        wagtail.core.blocks.StructBlock(
                            [
                                ("url", wagtail.core.blocks.URLBlock()),
                                ("title", wagtail.core.blocks.CharBlock()),
                                (
                                    "description",
                                    wagtail.core.blocks.TextBlock(required=False),
                                ),
                                ("image", wagtail.images.blocks.ImageChooserBlock()),
                            ]
                        ),
                    ),
                ],
                blank=True,
                help_text="Optional space for featured articles, max. 4",
                null=True,
            ),
github mozilla / donate-wagtail / donate / navigation / models.py View on Github external
from modelcluster.models import ClusterableModel
from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtail.contrib.settings.models import BaseSetting, register_setting
from wagtail.core import blocks
from wagtail.core.fields import StreamField


class LinkBlock(blocks.StructBlock):
    page = blocks.PageChooserBlock()
    title = blocks.CharBlock(help_text="Leave blank to use the page's own title", required=False)

    class Meta:
        template = 'blocks/menu_item.html',


@register_setting(icon='list-ul')
class NavigationSettings(BaseSetting, ClusterableModel):
    primary_navigation = StreamField(
        [('link', LinkBlock()), ],
        blank=True,
        help_text="Main site navigation"
    )

    panels = [
        StreamFieldPanel('primary_navigation'),
    ]
github thepoly / pipeline / core / migrations / 0008_auto_20190429_1807.py View on Github external
class Migration(migrations.Migration):

    dependencies = [("core", "0007_auto_20190429_1739")]

    operations = [
        migrations.AlterField(
            model_name="articlepage",
            name="body",
            field=wagtail.core.fields.StreamField(
                [
                    ("paragraph", wagtail.core.blocks.RichTextBlock()),
                    (
                        "photo",
                        wagtail.core.blocks.StructBlock(
                            [
                                ("image", wagtail.images.blocks.ImageChooserBlock()),
                                ("caption", wagtail.core.blocks.RichTextBlock()),
                            ]
                        ),
                    ),
                    (
                        "photo_gallery",
                        wagtail.core.blocks.ListBlock(
                            wagtail.snippets.blocks.SnippetChooserBlock("core.Photo"),
                            icon="image",
                        ),
                    ),
                    (
                        "embed",
                        wagtail.core.blocks.StructBlock(
github cartologic / cartoview / cartoview / cms / db_models / blocks / ImageLinkGalleryBlock.py View on Github external
from wagtail.core import blocks
from wagtail.images.blocks import ImageChooserBlock


class ImageLink(blocks.StructBlock):
    image = ImageChooserBlock(
        label='Image',
    )
    link = blocks.CharBlock(
        label='Link',
        max_length=200,
    )


class ImageLinkGalleryBlock(blocks.StructBlock):
    image_items = blocks.ListBlock(
        ImageLink(),
        label="Image",
    )
    single_image_width = blocks.IntegerBlock(
        help_text="in pixels"
    )

    class Meta:
        template = 'cms/blocks/image_link_gallery.html'