示例#1
0
class ChartBlock(blocks.StructBlock):
    title = blocks.CharBlock(
        label='Title',
        max_length=120,
        default='Chart Title',
    )
    chart_type = ChartChoiceBlock(
        label='Chart Type',
        default='bar'
    )
    labels = blocks.ListBlock(
        blocks.CharBlock(max_length=40, label="Label", default='Label'),
        label='Chart Labels',
    )
    datasets = blocks.ListBlock(
        ChartDataset(),
        label='Dataset',
    )

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context=parent_context)
        value['datasets'] = json.dumps(value['datasets'])
        return context

    class Meta:
        template = 'wagtail_blocks/chart.html'
        icon = 'fa-bar-chart'
示例#2
0
class CroppedImagesWithTextBlock(blocks.StructBlock):
    image_items = blocks.ListBlock(
        SingleImageWithText(),
        label="Image Item",
    )

    class Meta:
        template = 'wagtail_blocks/cropped_images_with_text.html'
        icon = 'fa-camera-retro'
示例#3
0
class ListBlock(blocks.StructBlock):
    content = blocks.ListBlock(
        blocks.CharBlock(),
        label='Items',
    )

    class Meta:
        template = 'wagtail_blocks/list.html'
        icon = "list-ul"
示例#4
0
class ImageSliderBlock(blocks.StructBlock):
    image_items = blocks.ListBlock(
        SingleImageSlide(),
        label="Image",
    )

    class Meta:
        template = 'wagtail_blocks/image_slider.html'
        icon = 'fa-slideshare'
示例#5
0
class ThumbnailGalleryBlock(blocks.StructBlock):
    image_items = blocks.ListBlock(
        SingleThumbnail(),
        label="Image",
    )

    class Meta:
        template = 'wagtail_blocks/thumbnail_gallery.html'
        icon = 'fa-object-ungroup'
示例#6
0
class ListWithImagesBlock(blocks.StructBlock):
    list_items = blocks.ListBlock(
        SingleListImage(),
        label="List Item",
    )

    class Meta:
        template = 'wagtail_blocks/list_with_images.html'
        icon = 'fa-id-card-o'
示例#7
0
class ChartDataset(blocks.StructBlock):
    label = blocks.CharBlock(
        label='Dataset Label',
        max_length=120,
        default='Dataset #1',
    )
    dataset_data = blocks.ListBlock(
        blocks.IntegerBlock(),
        label='Data',
        default='0',
    )
示例#8
0
class Migration(migrations.Migration):

    dependencies = [
        ('tests', '0012_pagewithrelatedpages'),
    ]

    operations = [
        migrations.AlterField(
            model_name='pagewithstreamfield',
            name='body',
            field=wagtail_fields.StreamField([('link_block', wagtail_blocks.StructBlock([('page', wagtail_blocks.PageChooserBlock(required=False)), ('text', wagtail_blocks.CharBlock(max_length=250))])), ('page', wagtail_blocks.PageChooserBlock()), ('stream', wagtail_blocks.StreamBlock([('page', wagtail_blocks.PageChooserBlock())])), ('rich_text', wagtail_blocks.RichTextBlock()), ('list_of_pages', wagtail_blocks.ListBlock(wagtail_blocks.PageChooserBlock()))], blank=True, verbose_name='Page body'),
        ),
    ]
class Migration(migrations.Migration):

    dependencies = [
        ('wagtailcore', '0041_group_collection_permissions_verbose_name_plural'),
        ('tests', '0004_pagewithrichtext'),
    ]

    operations = [
        migrations.CreateModel(
            name='PageWithStreamField',
            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')),
                ('body', wagtail_fields.StreamField([('link_block', wagtail_blocks.StructBlock([('page', wagtail_blocks.PageChooserBlock()), ('text', wagtail_blocks.CharBlock(max_length=250))])), ('page', wagtail_blocks.PageChooserBlock()), ('stream', wagtail_blocks.StreamBlock([('page', wagtail_blocks.PageChooserBlock())])), ('rich_text', wagtail_blocks.RichTextBlock()), ('list_of_pages', wagtail_blocks.ListBlock(wagtail_blocks.PageChooserBlock()))], blank=True, verbose_name='Page body')),
            ],
            options={
                'abstract': False,
            },
            bases=('wagtailcore.page',),
        ),
    ]