Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
): # noqa
super().__init__(**kwargs)
self.features = ["bold", "italic", "link"]
class Meta: # noqa
template = "streams/richtext_block.html"
icon = "edit"
label = "Simple RichText"
class CTABlock(blocks.StructBlock):
"""A simple call to action section."""
title = blocks.CharBlock(required=True, max_length=60)
text = blocks.RichTextBlock(required=True, features=["bold", "italic"])
button_page = blocks.PageChooserBlock(required=False)
button_url = blocks.URLBlock(required=False)
button_text = blocks.CharBlock(required=True, default='Learn More', max_length=40)
class Meta: # noqa
template = "streams/cta_block.html"
icon = "placeholder"
label = "Call to Action"
class LinkStructValue(blocks.StructValue):
"""Additional logic for our urls."""
def url(self):
button_page = self.get('button_page')
button_url = self.get('button_url')
if button_page:
migrations.AlterField(
model_name="topic",
name="tabbed_panels",
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(
help_text="External URL to link to instead of a page.",
required=False,
),
),
]
),
)
],
blank=True,
help_text="Optional tabbed panels for linking out to other resources, max. 3",
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [
('torchbox', '0096_revert_pr97'),
]
operations = [
migrations.AlterField(
model_name='servicepage',
name='streamfield',
field=wagtail.core.fields.StreamField([(b'paragraph', wagtail.core.blocks.RichTextBlock(icon='pilcrow')), (b'case_studies', wagtail.core.blocks.StructBlock([(b'title', wagtail.core.blocks.CharBlock(required=True)), (b'intro', wagtail.core.blocks.TextBlock(required=True)), (b'case_studies', wagtail.core.blocks.ListBlock(wagtail.core.blocks.StructBlock([('page', wagtail.core.blocks.PageChooserBlock('torchbox.WorkPage')), ('title', wagtail.core.blocks.CharBlock(required=False)), ('descriptive_title', wagtail.core.blocks.CharBlock(required=False)), ('image', wagtail.images.blocks.ImageChooserBlock(required=False))])))])), (b'highlights', wagtail.core.blocks.StructBlock([(b'title', wagtail.core.blocks.CharBlock(required=True)), (b'intro', wagtail.core.blocks.TextBlock(required=False)), (b'highlights', wagtail.core.blocks.ListBlock(wagtail.core.blocks.TextBlock()))])), (b'pull_quote', wagtail.core.blocks.StructBlock([(b'quote', wagtail.core.blocks.CharBlock(classname='quote title')), (b'attribution', wagtail.core.blocks.CharBlock())], template='blocks/pull_quote_block.html')), (b'process', wagtail.core.blocks.StructBlock([(b'title', wagtail.core.blocks.CharBlock(required=True)), (b'intro', wagtail.core.blocks.TextBlock(required=False)), (b'steps', wagtail.core.blocks.ListBlock(wagtail.core.blocks.StructBlock([('subtitle', wagtail.core.blocks.CharBlock(required=False)), ('title', wagtail.core.blocks.CharBlock(required=True)), ('icon', wagtail.core.blocks.CharBlock(help_text='Paste SVG code here', max_length=9000, required=True)), ('description', wagtail.core.blocks.TextBlock(required=True))])))])), (b'people', wagtail.core.blocks.StructBlock([(b'title', wagtail.core.blocks.CharBlock(required=True)), (b'intro', wagtail.core.blocks.TextBlock(required=True)), (b'people', wagtail.core.blocks.ListBlock(wagtail.core.blocks.PageChooserBlock()))])), (b'featured_pages', wagtail.core.blocks.StructBlock([(b'title', wagtail.core.blocks.CharBlock()), (b'pages', wagtail.core.blocks.ListBlock(wagtail.core.blocks.StructBlock([('page', wagtail.core.blocks.PageChooserBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('text', wagtail.core.blocks.TextBlock()), ('sub_text', wagtail.core.blocks.CharBlock(max_length=100))])))])), (b'sign_up_form_page', wagtail.core.blocks.StructBlock([(b'page', wagtail.core.blocks.PageChooserBlock('torchbox.SignUpFormPage'))])), (b'logos', wagtail.core.blocks.StructBlock([(b'title', wagtail.core.blocks.CharBlock()), (b'intro', wagtail.core.blocks.CharBlock()), (b'logos', wagtail.core.blocks.ListBlock(wagtail.core.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('link_page', wagtail.core.blocks.PageChooserBlock(required=False)), ('link_external', wagtail.core.blocks.URLBlock(required=False))])))]))]),
),
class Migration(migrations.Migration):
dependencies = [
('core', '0001_squashed_0077_molo_page'),
]
operations = [
migrations.AlterModelOptions(
name='reactionquestionresponse',
options={'permissions': (('can_view_response', 'Can view Response'),)},
),
migrations.AlterField(
model_name='articlepage',
name='body',
field=wagtail.core.fields.StreamField((('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', molo.core.blocks.MarkDownBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('list', wagtail.core.blocks.ListBlock(wagtail.core.blocks.CharBlock(label='Item'))), ('numbered_list', wagtail.core.blocks.ListBlock(wagtail.core.blocks.CharBlock(label='Item'))), ('page', wagtail.core.blocks.PageChooserBlock()), ('media', molo.core.models.MoloMediaBlock(icon='media'))), blank=True, null=True),
),
migrations.AlterField(
model_name='articlepage',
name='commenting_state',
field=models.CharField(blank=True, choices=[('O', 'Open'), ('C', 'Closed'), ('D', 'Disabled'), ('T', 'Timestamped')], max_length=1, null=True),
),
migrations.AlterField(
model_name='articlepage',
name='social_media_description',
field=models.TextField(blank=True, null=True, verbose_name='description'),
),
migrations.AlterField(
model_name='articlepage',
name='social_media_image',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image', verbose_name='Image'),
),
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'),
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [
('core', '0015_freebasics_banner_check'),
]
operations = [
migrations.AlterField(
model_name='articlepage',
name='body',
field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', molo.core.blocks.MarkDownBlock()), ('image', wagtail.images.blocks.ImageChooserBlock()), ('list', wagtail.core.blocks.ListBlock(wagtail.core.blocks.CharBlock(label='Item'))), ('numbered_list', wagtail.core.blocks.ListBlock(wagtail.core.blocks.CharBlock(label='Item'))), ('page', wagtail.core.blocks.PageChooserBlock()), ('media', molo.core.models.MoloMediaBlock(icon='media')), ('richtext', wagtail.core.blocks.RichTextBlock())], blank=True, null=True),
)
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [("topics", "0046_remove_topic_tabbed_panels_title")]
operations = [
migrations.AlterField(
model_name="topic",
name="featured",
field=wagtail.core.fields.StreamField(
[
(
"post",
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),
),
required=True,
help_text=_('Alternate text to show if the image doesn’t load'),
)
class Meta:
template = 'coderedcms/blocks/image_link_block.html'
icon = 'image'
label = _('Image Link')
value_class = LinkStructValue
class PageListBlock(BaseBlock):
"""
Renders a preview of selected pages.
"""
indexed_by = blocks.PageChooserBlock(
required=True,
label=_('Parent page'),
help_text=_(
"Show a preview of pages that are children of the selected page. Uses ordering specified in the page’s LAYOUT tab." # noqa
),
)
classified_by = ClassifierTermChooserBlock(
required=False,
label=_('Classified as'),
help_text=_('Only show pages that are classified with this term.')
)
show_preview = blocks.BooleanBlock(
required=False,
default=False,
label=_('Show body preview'),
)
import wagtail.core.fields
class Migration(migrations.Migration):
dependencies = [("home", "0010_auto_20190627_1527")]
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",
wagtail.core.blocks.StructBlock(
[
("title", wagtail.core.blocks.CharBlock()),
("description", wagtail.core.blocks.TextBlock()),
("url", wagtail.core.blocks.URLBlock()),
]
),
),
],
blank=True,
null=True,
import wagtail.core.fields
class Migration(migrations.Migration):
dependencies = [("home", "0003_homepage_featured_article")]
operations = [
migrations.AddField(
model_name="homepage",
name="featured_articles",
field=wagtail.core.fields.StreamField(
[
(
"article",
wagtail.core.blocks.PageChooserBlock(
target_model=["articles.ArticlePage"]
),
)
],
null=True,
),