Esempio n. 1
0
class TripleFrameBlock(StructBlock):

    columns = blocks.ChoiceBlock(label=_('Proportions'),
                                 choices=[
                                     ('4-4-4', _('1/3 + 1/3 + 1/3')),
                                     ('6-3-3', _('1/2 + 1/4 + 1/4')),
                                     ('3-6-3', _('1/4 + 1/2 + 1/4')),
                                     ('3-3-6', _('1/4 + 1/4 + 1/2')),
                                 ],
                                 required=True,
                                 default='4-4-4',
                                 icon='fa fa-columns')

    left = blocks.StreamBlock(STREAMFIELD_BLOCKS_NOFRAMES, icon='cogs')
    middle = blocks.StreamBlock(STREAMFIELD_BLOCKS_NOFRAMES, icon='cogs')
    right = blocks.StreamBlock(STREAMFIELD_BLOCKS_NOFRAMES, icon='cogs')

    class Meta(object):
        icon = 'fa fa-columns'
        template = 'cosinnus/wagtail/widgets/triple_frame.html'

    def get_context(self, value):
        context = super(TripleFrameBlock, self).get_context(value)
        context['left'] = value.get('left')
        context['middle'] = value.get('middle')
        context['right'] = value.get('right')
        context['columns'] = value.get('columns')
        return context
Esempio n. 2
0
class SidebarBlock(blocks.StructBlock):
	"""
	HalvesBlock is an example of a sub-block / component / pre-defined collection of HTML elements.  
	Using StructBlock sets this overall block to have a specific predefined format.
	This block can only consist of photo - title - text, and these fields are required.

	"""
	main_content = blocks.StreamBlock([
		('heading', blocks.CharBlock()),
        ('image', ImageChooserBlock()),
        ('text', blocks.TextBlock()),
        ('person', PersonBlock()),
        ('drink', DrinksChoiceBlock())])

	sidebar = blocks.StreamBlock([
		('heading', blocks.CharBlock()),
        ('image', ImageChooserBlock()),
        ('text', blocks.TextBlock()),
        ('person', PersonBlock()),
        ('drink', DrinksChoiceBlock())])


	class Meta:
		template = 'home/blocks/sidebar.html'
		icon = 'placeholder'
		form_classname = 'side-bar'
Esempio n. 3
0
class Thirds(blocks.StructBlock):
	"""1/3 width of the screen.  The idea here is that content type is flexable and based around structure.  
	Any content block that is split into thirds can be made to work inside here based on using StreamBlocks.
	Limitations are that there are no limitation.  Stream blocks allow you to keep adding content to them.  
	An either/or block solution would be ideal for this structure based approach.    

	"""
	thirds_heading = blocks.CharBlock(classname="full title")

	one_of_three = blocks.StreamBlock([
        ('image', ImageChooserBlock()),
        ('person', PersonBlock()),
        ('drink', DrinksChoiceBlock())])

	two_of_three = blocks.StreamBlock([
    	('image', ImageChooserBlock()),
    	('person', PersonBlock())])

	three_of_three = blocks.StreamBlock([
        ('image', ImageChooserBlock()),
        ('person', PersonBlock())])

	class Meta:
		icon = 'placeholder'
		template = 'home/blocks/thirds.html'
Esempio n. 4
0
class HeroDonateBlock(blocks.StructBlock):
    hero_image = ImageChooserBlock(required=False)
    background_color = blocks.TextBlock(required=False)
    padding = blocks.TextBlock(required=False)
    amount_one = blocks.TextBlock(required=False)
    amount_two = blocks.TextBlock(required=False)
    amount_three = blocks.TextBlock(required=False)
    amount_four = blocks.TextBlock(required=False)
    amount_five = blocks.TextBlock(required=False)
    amount_six = blocks.TextBlock(required=False)
    logo = blocks.ChoiceBlock(choices=[
        ('hide', 'Hide'),
        ('show', 'Show'),
        ('animate', 'Animate'),
    ])
    hero_content = blocks.StreamBlock([
        ('HTML', HtmlBlock()),
        ('WYSIWYG', WysiwygBlock()),
        ('Row', RowBlock()),
    ])
    thankyou_content = blocks.StreamBlock([
        ('HTML', HtmlBlock()),
        ('WYSIWYG', WysiwygBlock()),
        ('Row', RowBlock()),
    ])

    class Meta:
        template = 'blocks/hero_donate_block.html'
        icon = 'pick'
Esempio n. 5
0
class ResourceBlock(blocks.StructBlock):
    """A section of a ResourcePage"""
    title = blocks.CharBlock(required=True)
    hide_title = blocks.BooleanBlock(required=False, help_text='Should the section title be displayed?')
    content = blocks.StreamBlock([
        ('text', blocks.RichTextBlock(blank=False, null=False, required=False, icon='pilcrow')),
        ('documents', blocks.ListBlock(ThumbnailBlock(), template='blocks/section-documents.html', icon='doc-empty')),
        ('contact_info', ContactInfoBlock()),
        ('internal_button', InternalButtonBlock()),
        ('external_button', ExternalButtonBlock()),
        ('page', blocks.PageChooserBlock(template='blocks/page-links.html')),
        ('disabled_page', blocks.CharBlock(blank=False, null=False, required=False, template='blocks/disabled-page-links.html', icon='placeholder', help_text='Name of a disabled link')),
        ('document_list', blocks.ListBlock(FeedDocumentBlock(), template='blocks/document-list.html', icon='doc-empty')),
        ('current_commissioners', CurrentCommissionersBlock()),
        ('fec_jobs', CareersBlock()),
        ('mur_search', MURSearchBlock()),
        ('table', TableBlock()),
        ('html', blocks.RawHTMLBlock()),
        ('reporting_example_cards', ReportingExampleCards()),
        ('contribution_limits_table', SnippetChooserBlock('home.EmbedTableSnippet', template = 'blocks/embed-table.html', icon='table')),
    ])

    aside = blocks.StreamBlock([
        ('title', blocks.CharBlock(required=False, icon='title')),
        ('document', ThumbnailBlock()),
        ('link', AsideLinkBlock()),
    ],

    template='blocks/section-aside.html',
    icon='placeholder')

    class Meta:
        template = 'blocks/section.html'
Esempio n. 6
0
class TwoColumnBlock(blocks.StructBlock):
    COLOUR_CHOICES = (
        ('theme-white', 'White'),
        ('theme-black', 'Black'),
        ('theme-darker', 'Dark Gray'),
        ('theme-body-color', 'Body Color'),
        ('theme-primary', 'Primary Color'),
        ('theme-secondary', 'Secondary Color'),
    )

    background = blocks.ChoiceBlock(choices=COLOUR_CHOICES, default="white")

    left_column = blocks.StreamBlock([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('google_map', GoogleMapBlock()),
    ], icon='arrow-left', label='Left column content')

    right_column = blocks.StreamBlock([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('google_map', GoogleMapBlock()),
    ], icon='arrow-right', label='Right column content')

    class Meta:
        template = 'homepage/two_column_block.html'
        icon = 'placeholder'
        label = 'Two Columns'
Esempio n. 7
0
class ResourceBlock(blocks.StructBlock):
    """A section of a ResourcePage"""
    title = blocks.CharBlock(required=True)
    hide_title = blocks.BooleanBlock(
        required=False, help_text='Should the section title be displayed?')
    content = blocks.StreamBlock([
        ('text',
         blocks.RichTextBlock(blank=False,
                              null=False,
                              required=False,
                              icon='pilcrow')),
        ('documents',
         blocks.ListBlock(ThumbnailBlock(),
                          template='blocks/section-documents.html',
                          icon='doc-empty')),
        ('contact_info', ContactInfoBlock()),
        ('internal_button', InternalButtonBlock()),
        ('external_button', ExternalButtonBlock()),
        ('page', blocks.PageChooserBlock(template='blocks/page-links.html')),
        ('document_list',
         blocks.ListBlock(FeedDocumentBlock(),
                          template='blocks/document-list.html',
                          icon='doc-empty')),
        ('current_commissioners', CurrentCommissionersBlock()),
        ('fec_jobs', CareersBlock()), ('table', TableBlock())
    ])

    aside = blocks.StreamBlock(
        [('title', blocks.CharBlock(required=False, icon='title')),
         ('document', ThumbnailBlock()), ('link', AsideLinkBlock())],
        template='blocks/section-aside.html',
        icon='placeholder')

    class Meta:
        template = 'blocks/section.html'
Esempio n. 8
0
class ThreeColumnBlock(blocks.StructBlock):
    background = blocks.ChoiceBlock(choices=COLOUR_CHOICES, default="white")
    left_column = blocks.StreamBlock([
            ('heading', blocks.CharBlock(classname="full title")),
            ('paragraph', blocks.RichTextBlock()),
            ('image', ImageChooserBlock()),
            ('embedded_video', EmbedBlock()),
            ('google_map', GoogleMapBlock()),
        ], icon='arrow-left', label='Left column content')

    center_column = blocks.StreamBlock([
            ('heading', blocks.CharBlock(classname="full title")),
            ('paragraph', blocks.RichTextBlock()),
            ('image', ImageChooserBlock()),
            ('embedded_video', EmbedBlock()),
            ('google_map', GoogleMapBlock()),
        ], icon='arrow-right', label='Center column content')

    right_column = blocks.StreamBlock([
            ('heading', blocks.CharBlock(classname="full title")),
            ('paragraph', blocks.RichTextBlock()),
            ('image', ImageChooserBlock()),
            ('embedded_video', EmbedBlock()),
            ('google_map', GoogleMapBlock()),
        ], icon='arrow-right', label='Right column content')

    class Meta:
        template = 'home/includes/three_column_block.html'
        icon = 'placeholder'
        label = 'Three Columns'
Esempio n. 9
0
class TwoColumnBlock(blocks.StructBlock):
    left_column = blocks.StreamBlock(rich_text_blocks, icon='arrow-left',
                                     label=_('Left column content'))
    right_column = blocks.StreamBlock(rich_text_blocks, icon='arrow-right',
                                      label=_('Right column content'))

    class Meta:
        icon = 'placeholder'
        label = _('Two columns')
        template = 'content/blocks/two_column.html'
Esempio n. 10
0
class RightAlignedImage(blocks.StructBlock):

    left_column = blocks.StreamBlock([('paragraph', blocks.RichTextBlock())])

    right_column = blocks.StreamBlock([
        ('image', ImageChooserBlock()),
    ])

    class Meta:
        template = 'blog/right_aligned_image.html'
        icon = 'image'
Esempio n. 11
0
class TwoColumnCodeBlock(blocks.StructBlock):

    left_column = blocks.StreamBlock([
        ('left_code', CodeBlock()),
    ])

    right_column = blocks.StreamBlock([
        ('right_code', CodeBlock()),
    ])

    class Meta:
        template = 'blog/two_column_code_block.html'
        icon = 'code'
Esempio n. 12
0
class RightAlignedCodeBlock(blocks.StructBlock):

    left_column = blocks.StreamBlock([
        ('paragraph', blocks.RichTextBlock()),
    ])

    right_column = blocks.StreamBlock([
        ('code', CodeBlock()),
    ])

    class Meta:
        template = 'blog/right_aligned_code_block.html'
        icon = 'code'
Esempio n. 13
0
class ColumnsBlock(StructBlock):
    left_column = blocks.StreamBlock(CONTENT_BLOCKS + DATA_BLOCKS)
    right_column = blocks.StreamBlock(CONTENT_BLOCKS + DATA_BLOCKS,
                                      form_classname='pull-right')

    def get_context(self, value):
        context = super().get_context(value)
        context['left_column'] = value.get('left_column')
        context['right_column'] = value.get('right_column')
        return context

    class Meta:
        icon = 'fa fa-columns'
        label = 'Columns 1-1'
        template = None
Esempio n. 14
0
class ColSliderBlock(ColBlock):
    images = blocks.StreamBlock([
        ('image', ImageChooserBlock())
    ])

    class Meta:
        template = 'blocks/col_slider_block.html'
Esempio n. 15
0
class TwoColsBlock(blocks.StructBlock):

    #left = blocks.RichTextBlock(label='linkse kolom', required=True)
    #right = blocks.RichTextBlock(label='rechtse kolom', required=True)

    content = blocks.StreamBlock([
        ('linkse_kolom', blocks.RichTextBlock()),
        ('rechtse_kolom', blocks.RichTextBlock()),
    ],
                                 icon='arrow-left',
                                 label='inhoud')

    # left = blocks.StreamBlock([
    # 	('linkse_kolom', blocks.RichTextBlock()),

    # 	], icon='arrow-left', label='inhoud')

    # right = blocks.StreamBlock([
    # 	('rechtse_kolom', blocks.RichTextBlock()),

    # 	], icon='arrow-right', label='inhoud')

    class Meta:
        template = 'home/blocks/two_cols.html'
        icon = 'placeholder'
        label = '2 kolommen'
        form_classname = 'range'
Esempio n. 16
0
class Navigation(models.Model):
    title = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255)
    navigation = StreamField([
        ('menu_block',
         blocks.StructBlock([('title', blocks.CharBlock()),
                             ('menu_items',
                              blocks.ListBlock(
                                  blocks.StreamBlock([
                                      ('link_external',
                                       blocks.StructBlock([
                                           ('caption', blocks.CharBlock()),
                                           ('url', blocks.CharBlock()),
                                           ('mega_menu',
                                            blocks.BooleanBlock(
                                                label="Show_in_mega_menu",
                                                default=False,
                                                blank=True,
                                                required=False)),
                                       ])),
                                      ('link_page', blocks.PageChooserBlock()),
                                  ])))])),
    ],
                             blank=True)

    panels = [
        FieldPanel('title'),
        FieldPanel('slug'),
        StreamFieldPanel('navigation'),
    ]

    def __unicode__(self):
        return self.title
Esempio n. 17
0
class AppCard(blocks.StructBlock):
    """Twitter App Card

    Example:
        <meta name="twitter:card" content="app">
        <meta name="twitter:site" content="@TwitterDev">
        <meta name="twitter:description" content="Cannonball is the fun way to create and share stories and poems on your phone. Start with a beautiful image from the gallery, then choose words to complete the story and share it with friends.">
        <meta name="twitter:app:country" content="US">
        <meta name="twitter:app:name:iphone" content="Cannonball">
        <meta name="twitter:app:id:iphone" content="929750075">
        <meta name="twitter:app:url:iphone" content="cannonball://poem/5149e249222f9e600a7540ef">
        <meta name="twitter:app:name:ipad" content="Cannonball">
        <meta name="twitter:app:id:ipad" content="929750075">
        <meta name="twitter:app:url:ipad" content="cannonball://poem/5149e249222f9e600a7540ef">
        <meta name="twitter:app:name:googleplay" content="Cannonball">
        <meta name="twitter:app:id:googleplay" content="io.fabric.samples.cannonball">
        <meta name="twitter:app:url:googleplay" content="http://cannonball.fabric.io/poem/5149e249222f9e600a7540ef">
    """
    site = blocks.CharBlock(max_length=15, required=False)
    description = blocks.CharBlock(max_length=200, required=False)
    country = blocks.CharBlock(max_length=2, min_length=2)

    apps = blocks.StreamBlock([
        ('googleplay', GooglePlayAppBlock()),
        ('iphone', IPhoneAppBlock()),
        ('ipad', IPadAppBlock())
    ])

    class Meta:
        template = 'wagtailseo/cards/app.html'
Esempio n. 18
0
class LiveCleanColumnBlock(ColumnBlock):
    """Re-implementing Column block to add custom components"""

    content = blocks.StreamBlock(LIVE_CLEAN_BLOCKS + UNCHAINED_COMPONENTS_BLOCKS)

    class Meta:
        label = 'Column'
Esempio n. 19
0
class Slide(Page):
    contents = StreamField(base_stream_blocks + [
        ('flex_group',
         blocks.StreamBlock(
             base_stream_blocks, icon='doc-empty', label='Flex Group')),
    ])

    speaker_notes = RichTextField(blank=True, null=True)

    ordering = models.IntegerField()
    display_weaver = models.BooleanField(default=False)
    display_title = models.BooleanField(default=False)
    centered_slide = models.BooleanField(default=False)

    content_panels = Page.content_panels + [
        FieldPanel('ordering'),
        FieldPanel('display_weaver'),
        FieldPanel('display_title'),
        FieldPanel('centered_slide'),
        FieldPanel('speaker_notes'),
        StreamFieldPanel('contents'),
    ]

    api_fields = [
        'speaker_notes',
        'contents',
        'display_weaver',
        'display_title',
        'centered_slide',
        'ordering',
    ]
Esempio n. 20
0
class RelatedMetadata(blocks.StructBlock):
    slug = blocks.CharBlock(max_length=100)
    content = blocks.StreamBlock([
        ('text',
         blocks.StructBlock([('heading', blocks.CharBlock(max_length=100)),
                             ('blob', blocks.RichTextBlock())],
                            icon='pilcrow')),
        ('list',
         blocks.StructBlock([
             ('heading', blocks.CharBlock(max_length=100)),
             ('links', blocks.ListBlock(atoms.Hyperlink())),
         ],
                            icon='list-ul')),
        ('date',
         blocks.StructBlock([('heading', blocks.CharBlock(max_length=100)),
                             ('date', blocks.DateBlock())],
                            icon='date')),
        ('topics',
         blocks.StructBlock([
             ('heading', blocks.CharBlock(max_length=100, default='Topics')),
             ('show_topics', blocks.BooleanBlock(default=True, required=False))
         ],
                            icon='tag')),
    ])
    is_half_width = blocks.BooleanBlock(required=False, default=False)

    class Meta:
        icon = 'grip'
        template = '_includes/molecules/related-metadata.html'
        label = 'Related metadata'
Esempio n. 21
0
    def test_include_block_tag_with_streamvalue(self):
        """
        The include_block tag should be able to render a StreamValue's template
        while keeping the parent template's context
        """
        block = blocks.StreamBlock(
            [
                ('heading',
                 blocks.CharBlock(template='tests/jinja2/heading_block.html')),
                ('paragraph', blocks.CharBlock()),
            ],
            template='tests/jinja2/stream_with_language.html')

        stream_value = block.to_python([{
            'type': 'heading',
            'value': 'Bonjour'
        }])

        result = render_to_string('tests/jinja2/include_block_test.html', {
            'test_block': stream_value,
            'language': 'fr',
        })

        self.assertIn(
            '<div class="heading" lang="fr"><h1 lang="fr">Bonjour</h1></div>',
            result)
Esempio n. 22
0
    def test_initialisation(self):
        block = blocks.StreamBlock([
            ('heading', blocks.CharBlock()),
            ('paragraph', blocks.CharBlock()),
        ])

        self.assertEqual(list(block.child_blocks.keys()), ['heading', 'paragraph'])
class AgendaPage(Page):
    author= models.CharField(max_length=255)
    date = models.DateField('Post date')
    agenda = StreamField([
        ('agenda_item', blocks.StreamBlock([
            ('item_title', blocks.TextBlock()),
            ('item_content', blocks.ListBlock(blocks.StructBlock([
                ('item_text', blocks.TextBlock()),
                ('mtg_doc', blocks.StructBlock([
                    ('doc_description', blocks.TextBlock()),
                    ('doc_link', blocks.TextBlock())
                ]))
            ])))

        ]
        #,
        #template='blocks/agenda_temp.html',
        ))
    ])




    content_panels = Page.content_panels + [
        FieldPanel('author'),
        FieldPanel('date'),
        StreamFieldPanel('agenda'),

    ]
Esempio n. 24
0
    def test_initialisation_with_binary_string_names(self):
        # migrations will sometimes write out names as binary strings, just to keep us on our toes
        block = blocks.StreamBlock([
            (b'heading', blocks.CharBlock()),
            (b'paragraph', blocks.CharBlock()),
        ])

        self.assertEqual(list(block.child_blocks.keys()), [b'heading', b'paragraph'])
Esempio n. 25
0
class Columns1To1Block(StructBlock):
    left_column = blocks.StreamBlock(CONTENT_BLOCKS + DATA_BLOCKS)
    right_column = blocks.StreamBlock(CONTENT_BLOCKS + DATA_BLOCKS,
                                      form_classname='pull-right')

    def get_context(self, value, parent_context=None):
        context = super().get_context(value, parent_context)

        for column in ['left_column', 'right_column']:
            context[column] = value.get(column)

        return context

    class Meta:
        label = 'Two Columns'
        template = 'widgets/two-columns.html'
        icon = 'fa fa-columns'
Esempio n. 26
0
class AccordionBlock(ColBlock):

    accordion_items = blocks.StreamBlock([
        ('accordion_item', AccordionItemBlock())
    ])

    class Meta:
        template = 'blocks/accordion_block.html'
Esempio n. 27
0
class AccordionWithTitleBlock(ColBlock):
    title = blocks.CharBlock()
    accordion_items = blocks.StreamBlock([
        ('accordion_item', AccordionItemBlock())
    ])

    class Meta:
        template = 'blocks/accordion_with_title_block.html'
Esempio n. 28
0
class QuadFrameBlock(StructBlock):

    left = blocks.StreamBlock(STREAMFIELD_BLOCKS_NOFRAMES, icon='cogs')
    middle_left = blocks.StreamBlock(STREAMFIELD_BLOCKS_NOFRAMES, icon='cogs')
    middle_right = blocks.StreamBlock(STREAMFIELD_BLOCKS_NOFRAMES, icon='cogs')
    right = blocks.StreamBlock(STREAMFIELD_BLOCKS_NOFRAMES, icon='cogs')

    class Meta(object):
        icon = 'fa fa-columns'
        template = 'cosinnus/wagtail/widgets/quad_frame.html'

    def get_context(self, value):
        context = super(QuadFrameBlock, self).get_context(value)
        context['left'] = value.get('left')
        context['middle_left'] = value.get('middle_left')
        context['middle_right'] = value.get('middle_right')
        context['right'] = value.get('right')
        return context
Esempio n. 29
0
class Expandable(BaseExpandable):
    content = blocks.StreamBlock([
        ('paragraph', blocks.RichTextBlock(required=False)),
        ('links', atoms.Hyperlink()),
        ('email', ContactEmail()),
        ('phone', ContactPhone()),
        ('address', ContactAddress()),
    ],
                                 blank=True)
Esempio n. 30
0
class SpotlightBlock(StructBlockWithStyle):
    bubbles = blocks.StreamBlock([
        ('bubble_block', SpotlightBubbleBlock()),
    ])

    class Meta:
        template = 'common/blocks/spotlight_block.html'
        icon = 'image'
        label = 'Spotlight Block'