Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import wagtail.images.blocks
import wagtail.core.fields
import wagtail.embeds.blocks
class Migration(migrations.Migration):
dependencies = [
('home', '0023_merge'),
]
operations = [
migrations.AddField(
model_name='homepage',
name='body_mt',
field=wagtail.core.fields.StreamField((('image', wagtail.images.blocks.ImageChooserBlock(icon='image')), ('info_block', wagtail.core.blocks.StructBlock((('title', wagtail.core.blocks.CharBlock(required=False, classname='full title')), ('image', wagtail.images.blocks.ImageChooserBlock(required=False)), ('text', wagtail.core.blocks.RichTextBlock(required=False)), ('button', wagtail.core.blocks.StructBlock((('internal_link', wagtail.core.blocks.PageChooserBlock(required=False)), ('external_link', wagtail.core.blocks.URLBlock(required=False)), ('link_text', wagtail.core.blocks.TextBlock(required=False))), required=False)), ('highlight', wagtail.core.blocks.ChoiceBlock(icon='cup', required=False, choices=[('', 'None'), ('highlight', 'Highlight (blue)'), ('boxed', 'Boxed'), ('boxed2', 'Boxed Variation'), ('highlight-purple', 'Highlight (purple)')], help_text='How should this block be displayed?')), ('alignment', wagtail.core.blocks.ChoiceBlock(icon='cup', choices=[('vertical', 'vertical'), ('horizontal', 'horizontal')], help_text='How should the text and image be aligned?'))))), ('video_block', wagtail.core.blocks.StructBlock((('title', wagtail.core.blocks.CharBlock(classname='full title')), ('video', wagtail.embeds.blocks.EmbedBlock())))), ('news_block', wagtail.core.blocks.StructBlock((('title', wagtail.core.blocks.CharBlock(classname='full title')), ('news', wagtail.core.blocks.CharBlock(classname='full title'))))), ('rss_feed', wagtail.core.blocks.StructBlock((('feed', wagtail.snippets.blocks.SnippetChooserBlock(required=True, target_model=home.models.snippets.RSSImport)),))), ('column_block', wagtail.core.blocks.StructBlock((('title_col1', wagtail.core.blocks.CharBlock(required=False, classname='full title')), ('image_col1', wagtail.images.blocks.ImageChooserBlock(required=False)), ('text_col1', wagtail.core.blocks.RichTextBlock(required=False)), ('title_col2', wagtail.core.blocks.CharBlock(required=False, classname='full title')), ('image_col2', wagtail.images.blocks.ImageChooserBlock(required=False)), ('text_col2', wagtail.core.blocks.RichTextBlock(required=False)), ('title_col3', wagtail.core.blocks.CharBlock(required=False, classname='full title')), ('image_col3', wagtail.images.blocks.ImageChooserBlock(required=False)), ('text_col3', wagtail.core.blocks.RichTextBlock(required=False)))))), blank=True, null=True),
),
migrations.AddField(
model_name='homepage',
name='intro_mt',
field=models.CharField(default='Ever wondered how to get young people involved in politics online?OPIN, a European toolbox for youth eParticipation projects, shows you how.', blank=True, max_length=255, verbose_name='Subtitle'),
),
migrations.AddField(
model_name='homepage',
name='title_mt',
field=models.CharField(blank=True, max_length=255, verbose_name='Header Title'),
),
migrations.AddField(
model_name='manualsdetailpage',
name='body_mt',
field=wagtail.core.fields.StreamField((('heading', wagtail.core.blocks.CharBlock(icon='title', classname='full title')), ('paragraph', wagtail.core.blocks.TextBlock(icon='pilcrow')), ('rich_text', wagtail.core.blocks.RichTextBlock(icon='pilcrow')), ('video_block', wagtail.core.blocks.StructBlock((('title', wagtail.core.blocks.CharBlock(classname='full title')), ('video', wagtail.embeds.blocks.EmbedBlock())))), ('image', wagtail.images.blocks.ImageChooserBlock(icon='image')), ('accordion_block', wagtail.core.blocks.StructBlock((('accordion_items', wagtail.core.blocks.ListBlock(wagtail.core.blocks.StructBlock((('title', wagtail.core.blocks.TextBlock(required=False)), ('content', wagtail.core.blocks.RichTextBlock(required=False)))))),), icon='collapse-down'))), blank=True, verbose_name='body', null=True),
),
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"
),
),
],
help_text="Details of an external page",
),
table = TableBlock(icon='table')
code = CodeBlock(icon='code')
class Meta:
help_text = 'The main page body.'
class ContentStreamBlockWithRawCode(ContentStreamBlock):
raw_code = CodeBlock(
icon='code',
language='html',
template='wagtailcodeblock/raw_code.html',
)
class SectionStructBlock(StructBlock):
"""
Contains the elements we'll want to have in a Sectioned Content Stream block.
"""
section_heading = TextBlock(
icon='title',
help_text='Heading for this section.',
)
body = ContentStreamBlock(
help_text='The body content goes here.',
)
class Meta:
template = 'wagtailcontentstream/blocks/section_struct_block.html'
icon = 'doc-full-inverse'
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [("topics", "0020_auto_20190701_1104")]
operations = [
migrations.AlterField(
model_name="topic",
name="get_started",
field=wagtail.core.fields.StreamField(
[
(
"panel",
wagtail.core.blocks.StructBlock(
[
("title", wagtail.core.blocks.CharBlock()),
("image", wagtail.images.blocks.ImageChooserBlock()),
("description", wagtail.core.blocks.TextBlock()),
("button_text", wagtail.core.blocks.CharBlock()),
(
"page_link",
wagtail.core.blocks.PageChooserBlock(
required=False
),
),
(
"external_link",
wagtail.core.blocks.URLBlock(required=False),
),
name = models.CharField(max_length=255)
election_site_id = models.IntegerField(default=-1)
autocomplete_search_field = "name"
def autocomplete_label(self):
return self.name
@classmethod
def autocomplete_create(kls: type, value: str):
return kls.objects.create(name=value)
def __str__(self):
return self.name
class CandidateBlock(StructBlock):
image = ImageChooserBlock()
caption = RichTextBlock(features=["italic"], required=False)
@register_snippet
class Position(models.Model):
title = models.CharField(max_length=100)
def __str__(self):
return self.title
@register_snippet
class Term(Orderable, models.Model):
position = models.ForeignKey(
Position, on_delete=models.PROTECT, related_name="terms"
"'Find Out More' button URL", default="https://takwimu.zendesk.com/")
cta_two_name = models.TextField(
"Second button Name (optional)", blank=True)
cta_two_url = models.URLField("Second button URL (optional)", blank=True)
search_fields = [
index.SearchField('question'),
index.SearchField('answer'),
]
def __str__(self):
return self.question.encode('ascii', 'ignore')
# HURUmap style widget for FeaturedData.
class FeaturedDataWidgetBlock(blocks.StructBlock):
title = blocks.CharBlock(required=True, default="")
data_country = blocks.ChoiceBlock(required=True,
choices=[
('ET', 'Ethiopia'),
('KE', 'Kenya'),
('NG', 'Nigeria'),
('SN', 'Senegal'),
('TZ', 'Tanzania'),
],
label='Country')
data_id = blocks.ChoiceBlock(required=True,
choices=HURUMAP_DATA_DISTS,
label='Data')
chart_type = blocks.ChoiceBlock(required=True,
choices=[
('histogram', 'Histogram'),
def resolve_blocks(self, info, **kwargs):
stream_blocks = []
for field in self.value.stream_data:
block = self.value.stream_block.child_blocks[field["type"]]
if not issubclass(type(block), blocks.StructBlock):
value = block.to_python(field["value"])
stream_blocks.append(StructBlockItem(field["type"], block, field["value"]))
return stream_blocks
operations = [
migrations.AddField(
model_name="externalarticle",
name="authors",
field=wagtail.core.fields.StreamField(
[
(
"author",
wagtail.core.blocks.PageChooserBlock(
page_type=["people.Person"]
),
),
(
"external_author",
wagtail.core.blocks.StructBlock(
[
("title", wagtail.core.blocks.CharBlock(label="Name")),
("image", wagtail.images.blocks.ImageChooserBlock()),
(
"url",
wagtail.core.blocks.URLBlock(
label="URL", required=False
),
),
]
),
),
],
blank=True,
null=True,
),
icon = 'placeholder'
label = 'Two Columns'
template = "blocks/two_column_block.html"
class ThreeColumnBlock(StructBlock):
left_column = RichTextBlock(icon='arrow-right', label='Left column content')
middle_column = RichTextBlock(icon='arrow-up', label='Middle column content')
right_column = RichTextBlock(icon='arrow-right', label='Right column content')
class Meta:
icon = 'placeholder'
label = 'Three Columns'
template = "blocks/three_column_block.html"
class ImageBlock(StructBlock):
"""
Custom `StructBlock` for utilizing images with associated caption and
attribution data
"""
image = ImageChooserBlock(required=True)
caption = CharBlock(required=False)
attribution = CharBlock(required=False)
class Meta:
icon = 'image'
template = "blocks/image_block.html"
class HeadingBlock(StructBlock):
"""
Custom `StructBlock` that allows the user to select h2 - h4 sizes for headers
operations = [
migrations.AlterField(
model_name="blogpage",
name="body",
field=wagtail.core.fields.StreamField(
[
("heading", wagtail.core.blocks.CharBlock(classname="full title")),
("paragraph", wagtail.core.blocks.RichTextBlock()),
("image", wagtail.images.blocks.ImageChooserBlock()),
("decimal", wagtail.core.blocks.DecimalBlock()),
("date", wagtail.core.blocks.DateBlock()),
("datetime", wagtail.core.blocks.DateTimeBlock()),
(
"gallery",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
classname="full title"
),
),
(
"images",
wagtail.core.blocks.StreamBlock(
[
(
"image",
wagtail.core.blocks.StructBlock(
[
(