Beispiel #1
0
class CMSStreamBlock(StreamBlock):
    banner = BannerBlock(label='Banner section')
    ordered_list = OrderedListBlock(
        label='Ordered list section',
        help_text='Use this for sections similar to process')
    unordered_list = UnorderedListBlock(
        label='Unordered list block section',
        help_text='Use this for sections similar to services')
    image_list = ImageListBlock(label='Image list section')
    image_grid = ImageGridBlock(label='Image grid section', icon='table')
    featured_pages = FeaturedPageBlock(label='Featured pages section',
                                       icon='doc-full')
    live_feeds = LiveFeedsBlock(label='Live feeds section (blog/twitter)',
                                icon='wagtail')

    h2 = CharBlock(icon='title', classname='title')
    h3 = CharBlock(icon='title', classname='title')
    h4 = CharBlock(icon='title', classname='title')
    h5 = CharBlock(icon='title', classname='title')

    intro = RichTextBlock(icon='pilcrow')
    paragraph = RichTextBlock(icon='pilcrow')
    pullquote = PullQuoteBlock(icon='openquote')

    image = ImageBlock(label='Aligned image', icon='image')
    document = DocumentChooserBlock(icon='doc-full-inverse')
    link = LinkBlock(icon='link')
    embed = EmbedBlock(icon='media')

    html = AlignedHTMLBlock(icon='code', label='Raw HTML')
Beispiel #2
0
class AsciinemaBlock(blocks.StructBlock):
    FONT_SIZE = (
        ('small', _('small')),
        ('medium', _('medium')),
        ('big', _('big')),
    )
    THEME = (
        ('asciinema', ) * 2,
        ('tango', ) * 2,
        ('solarized-dark', ) * 2,
        ('solarized-light', ) * 2,
        ('monokai', ) * 2,
    )

    title = blocks.CharBlock(required=False)
    poster = blocks.CharBlock(
        required=False,
        default='npt:0:0',
        help_text=_('npt:2:34 || data:text/plain,Poster text'))
    document = DocumentChooserBlock(required=True)
    font_size = blocks.ChoiceBlock(FONT_SIZE, default='small')
    theme = blocks.ChoiceBlock(THEME, default='monokai')
    speed = blocks.IntegerBlock(default=1, min_value=1)
    start_at = blocks.CharBlock(default='0',
                                help_text=_('123, mm:ss, hh:mm:ss'))
    cols = blocks.IntegerBlock(default=0, min_value=0, max_value=1024)
    rows = blocks.IntegerBlock(default=5, min_value=0, max_value=1024)
    loop = blocks.BooleanBlock(default=False, required=False)
    preload = blocks.BooleanBlock(default=False, required=False)
    autoplay = blocks.BooleanBlock(default=False, required=False)

    class Meta:
        icon = 'media'
        template = 'wagtail_asciinema/blocks/asciinema_block.html'
Beispiel #3
0
class BlogStreamBlock(StreamBlock):
    h2 = CharBlock(icon="title", classname="title")
    paragraph = RichTextBlock(icon="pilcrow")
    aligned_image = ImageBlock(label="Aligned image", icon="image")
    pullquote = PullQuoteBlock()
    aligned_html = AlignedHTMLBlock(icon="code", label='Raw HTML')
    document = DocumentChooserBlock(icon="doc-full-inverse")
Beispiel #4
0
class DocumentBlock(blocks.StructBlock):
    document = DocumentChooserBlock()
    title = blocks.CharBlock(required=False)

    class Meta:
        icon = "doc-full-inverse"
        template = "blocks/document_block.html"
Beispiel #5
0
class LinkButtonBlock(ColBlock):
    title = blocks.CharBlock()
    page = blocks.PageChooserBlock(required=False)
    document = DocumentChooserBlock(required=False)

    class Meta:
        template = 'blocks/link_button_block.html'
Beispiel #6
0
class FeedDocumentBlock(blocks.StructBlock):
    """A block that is used to construct a feed list of PDFs"""
    title = blocks.CharBlock()
    document = DocumentChooserBlock()

    class Meta:
        icon = 'doc-empty'
Beispiel #7
0
class WgoBlock(StructBlock):
    sgf = DocumentChooserBlock()
    alignment = WgoAlignmentChoiceBlock()
    width = IntegerBlock(default=700)
    class Meta:
        icon = "placeholder"
        template = "wgo/wgoblock.html"
Beispiel #8
0
class Project(Page):
    parent_page_types = ["projects.ProjectIndex"]
    tagline = models.CharField(max_length=128, blank=True, null=True)
    body = StreamField([('heading', blocks.CharBlock(classname="full title")),
                        ('paragraph', blocks.RichTextBlock()),
                        ('image', ImageChooserBlock()),
                        ('document', DocumentChooserBlock()),
                        ('equation', MathBlock())])

    octopart_bom = models.URLField(blank=True, null=True)
    tags = ClusterTaggableManager(through=ProjectTag, blank=True)

    @property
    def products(self):
        products = [
            # Grabs rows from the relationship index and formats them correctly.
            n.products for n in self.project_product_relationship.all()
        ]
        return products

    # Only inline panels work here.
    content_panels = Page.content_panels + [
        FieldPanel('tagline'),
        StreamFieldPanel('body'),
        FieldPanel('octopart_bom'),
        InlinePanel('project_product_relationship', label='products'),
        InlinePanel('schematics', label='schematics'),
        FieldPanel('tags'),
    ]
Beispiel #9
0
class BlogStreamBlock(StreamBlock):
    paragraph = RichTextBlock(icon="pilcrow")
    aligned_image = ImageBlock(label="Aligned image", icon="image")
    pullquote = PullQuoteBlock()
    aligned_html = AlignedHTMLBlock(icon="code", label='Raw HTML')
    document = DocumentChooserBlock(icon="doc-full-inverse")
    embed = EmbedBlock(icon="media", label="Embed Media URL")
Beispiel #10
0
class ProtocolBlock(StructBlock):
    complete_pdf = DocumentChooserBlock(label='Complete PDF')
    pdfs = ListBlock(PDFBlock(), label='Chapter PDFs')
    image = ImageBlock()
    version = CharBlock()

    class Meta:
        icon = 'fa fa-newspaper-o'
        template = 'blocks/protocol_block.html'

    def get_context(self, value, parent_context=None):
        context = super(ProtocolBlock,
                        self).get_context(value, parent_context=parent_context)
        context['links'] = []
        for pdf in value.get('pdfs'):
            context['links'] += [{
                'fontawesome': 'file-pdf-o',
                'href': pdf.get('file').url,
                'text': pdf.get('description')
            }]
        try:
            rendition = value.get('image').get_rendition('max-500x500')
            context['image'] = {
                'url': rendition.url,
                'name': value.get('image').title
            }
        except:
            pass
        return context
Beispiel #11
0
class FAQBlock(blocks.StructBlock):
    question = blocks.RichTextBlock(required=True)
    slug = blocks.CharBlock(required=True)
    answer = blocks.RichTextBlock(required=True)
    document = DocumentChooserBlock(required=False)

    class Meta:
        icon = 'placeholder'
Beispiel #12
0
class BlogPage(Page):
    def main_image(self):
        gallery_item = self.gallery_images.first()
        if gallery_item:
            return gallery_item.image
        else:
            return None

    date = models.DateField("Post date")
    intro = models.CharField(max_length=250)
    body = RichTextField(blank=True)
    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
    categories = ParentalManyToManyField('blog.BlogCategory', blank=True)
    page_content = StreamField([
        ('h2_heading', blocks.CharBlock(classname="full title", icon="title")),
        ('paragraph', blocks.RichTextBlock()),
        ('blockquote', blocks.BlockQuoteBlock()),
        ('document', DocumentChooserBlock()),
        ('image', ImageChooserBlock(icon="image")),
        ('embed', EmbedBlock()),
        ('link', blocks.URLBlock()),
        ('codeblock', CodeBlock()),
    ],
                               null=True,
                               blank=True)
    # media = models.ForeignKey(
    #     'wagtailmedia.Media',
    #     null=True,
    #     blank=True,
    #     on_delete=models.SET_NULL,
    #     related_name='+'
    # )
    video = models.ForeignKey('wagtail_embed_videos.EmbedVideo',
                              verbose_name="Video",
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')

    search_fields = Page.search_fields + [
        index.SearchField('intro'),
        index.SearchField('body'),
    ]

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('date'),
            FieldPanel('tags'),
            FieldPanel('categories', widget=forms.CheckboxSelectMultiple),
        ],
                        heading="Blog information"),
        FieldPanel('intro'),
        FieldPanel('body', classname="full"),
        StreamFieldPanel('page_content'),
        # MediaChooserPanel('media'),  # this breaks the WYSIWYG, so I'm not using it anymore
        EmbedVideoChooserPanel('video'),
        InlinePanel('gallery_images', label="Gallery images"),
    ]
Beispiel #13
0
class BlogStreamBlock(StreamBlock):
    h2 = CharBlock(icon="title", classname="title")
    h3 = CharBlock(icon="title", classname="title")
    h4 = CharBlock(icon="title", classname="title")
    paragraph = RichTextBlock(icon="pilcrow")
    image = ImageChooserBlock()
    pullquote = PullQuoteBlock()
    document = DocumentChooserBlock(icon="doc-full-inverse")
    code = CodeBlock()
Beispiel #14
0
class ProductStreamBlock(StreamBlock):
    h2 = CharBlock(icon="title", classname="title")
    h3 = CharBlock(icon="title", classname="title")
    h4 = CharBlock(icon="title", classname="title")
    intro = TextBlock(icon="pilcrow")
    paragraph = RichTextBlock(icon="pilcrow")
    aligned_image = ImageBlock(label="Aligned image", icon="image")
    embed = EmbedBlock()
    document = DocumentChooserBlock(icon="doc-full-inverse")
Beispiel #15
0
class ContentStreamBlock(StreamBlock):
    h2 = CharBlock(icon="title", classname="title")
    h3 = CharBlock(icon="title", classname="title")
    h4 = CharBlock(icon="title", classname="title")
    intro = RichTextBlock(icon="pilcrow", label=u'简介')
    paragraph = RichTextBlock(icon="pilcrow", label=u'段落')
    aligned_image = ImageBlock(label=u'图片', icon="image")
    pullquote = PullQuoteBlock(label=u'引言')
    aligned_html = AlignedHTMLBlock(icon="code", label=u'HTML 代码')
    document = DocumentChooserBlock(icon="doc-full-inverse", label=u'请选择文本')
Beispiel #16
0
class LocalVideoBlock(blocks.StructBlock):
    standard = DocumentChooserBlock(
        label='Standard-Datei',
        help_text=
        'Video-Datei für standarkonforme Browser (Container webm, Codec: V8.0, Audio: Ogg)'
    )
    alt1 = DocumentChooserBlock(
        label='Alternative 1',
        help_text=
        'alternative Video-Datei (bspw. für Apple-Safari: Container mp4, Codec: H.264, Audio)',
        required=False)
    alt2 = DocumentChooserBlock(
        label='Alternative 2',
        help_text='alternative Video-Datei (bspw. für Internet-Explorer)',
        required=False)

    class Meta:
        label = 'Lokales Video'
        template = 'articles/blocks/video.html'
        help_text = 'Ein Video, das vom Schützen-Server geliefert wird und in den Text eingefügt wird.'
Beispiel #17
0
class HomeStreamBlock(StreamBlock):
    h2 = CharBlock(icon="title", classname="title")
    h3 = CharBlock(icon="title", classname="title")
    h4 = CharBlock(icon="title", classname="title")
    intro = RichTextBlock(icon="pilcrow")
    paragraph = RichTextBlock(icon="pilcrow")
    aligned_image = ImageBlock(label="Aligned image", icon="image")
    pullquote = PullQuoteBlock()
    aligned_html = AlignedHTMLBlock(icon="code", label='Raw HTML')
    document = DocumentChooserBlock(icon="doc-full-inverse")
    table = TableBlock(template='home/includes/table.html')
Beispiel #18
0
class BodyStreamBlock(StreamBlock):
    heading = HeadingBlock()
    paragraph = CustomRichTextBlock(
        features=['bold', 'italic', 'ol', 'ul', 'hr', 'link', 'document-link'])
    image = ImageBlock()
    blockquote = BlockQuoteBlock()
    embed = EmbedBlock()
    document = DocumentChooserBlock()
    code = CodeBlock()
    raw_html = RawHTMLBlock()
    table = TableBlock()
Beispiel #19
0
class ColumnBlock(blocks.StructBlock):
    heading = blocks.CharBlock(required=False)
    content = blocks.RichTextBlock(required=False)
    image = ImageBlock(
        required=False,
        help_text='Callout boxes 940x400, Home page boxes 1464x640')
    document = DocumentChooserBlock(required=False)
    cta = blocks.CharBlock(required=False)
    link = blocks.URLBlock(required=False)

    class Meta:
        icon = 'placeholder'
Beispiel #20
0
class HomeStreamBlock(StreamBlock):
    h2 = CharBlock(icon="title", classname="title")
    h3 = CharBlock(icon="title", classname="title")
    h4 = CharBlock(icon="title", classname="title")
    intro = RichTextBlock(icon="pilcrow")
    paragraph = RichTextBlock(icon="pilcrow")
    aligned_image = ImageBlock(label="Aligned image", icon="image")
    pullquote = PullQuoteBlock()
    aligned_html = AlignedHTMLBlock(icon="code", label='Raw HTML')
    document = DocumentChooserBlock(icon="doc-full-inverse")
    one_column = OneColumnBlock()
    two_columns = TwoColumnBlock()
    three_columns = ThreeColumnBlock()
Beispiel #21
0
class PDFBlock(StructBlock):
    file = DocumentChooserBlock()
    description = CharBlock()

    def get_context(self, value, parent_context=None):
        context = super(PDFBlock,
                        self).get_context(value, parent_context=parent_context)
        context['button'] = {'text': 'Download', 'href': value.get('file').url}
        context['description'] = value.get('description')
        context['fontawesome'] = 'file-pdf-o'
        return context

    class Meta:
        icon = 'fa fa-file-pdf-o'
        template = 'widgets/download-link.html'
Beispiel #22
0
class PressStreamBlock(StreamBlock):
    heading = CharBlock(icon="title", classname="title")
    subheading = CharBlock(icon="title", classname="title")
    text = RichTextBlock(icon="pilcrow",
                         features=['bold', 'italic', 'ul', 'ol', 'link'])
    image = ImageChooserBlock(template='press/blocks/image.html')
    image_gallery = ListBlock(CaptionedImageBlock(),
                              icon="image",
                              label="Image Slideshow")
    #image_or_video_gallery = ListBlock(CarouselBlock(), icon="image", label="Image or Video Slideshow")
    video = EmbedBlock()
    project = PageChooserBlock(target_model='design.ProjectPage',
                               template='design/blocks/related_project.html')
    pullquote = BlockQuoteBlock()
    document = DocumentChooserBlock(icon="doc-full-inverse")
Beispiel #23
0
class BureauStructure(blocks.StructBlock):
    last_updated_date = blocks.DateBlock(required=False)
    download_image = DocumentChooserBlock(icon='image')
    director = blocks.CharBlock()
    divisions = blocks.ListBlock(BureauStructureDivision())
    office_of_the_director = blocks.ListBlock(BureauStructureOffice(),
                                              label='Office of the Director')

    class Meta:
        icon = None
        template = '_includes/organisms/bureau-structure.html'
        icon = "table"

    class Media:
        js = ['bureau-structure.js']
Beispiel #24
0
class HomePage(Page):
    intro = RichTextField(blank=True)

    body = StreamField([
        ('text', blocks.RichTextBlock()),
        ('blockquote', blocks.BlockQuoteBlock()),
        ('image', ImageChooserBlock(template='wagtail_blocks/image.html')),
        ('document', DocumentChooserBlock()),
        ('embed', EmbedBlock(template='wagtail_blocks/embed.html')),
    ], blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('intro'),
        StreamFieldPanel('body'),
    ]
Beispiel #25
0
class CTDataStreamBlock(StreamBlock):
    h2 = CharBlock(icon="title", classname="title")
    h3 = CharBlock(icon="title", classname="title")
    h4 = CharBlock(icon="title", classname="title")
    intro = RichTextBlock(icon="pilcrow")
    paragraph = RichTextBlock(icon="pilcrow")
    aligned_image = ImageBlock(label="Aligned image", icon="image")
    pullquote = PullQuoteBlock()
    aligned_html = AlignedHTMLBlock(icon="code", label='Raw HTML')
    document = DocumentChooserBlock(icon="doc-full-inverse")
    pym_iframe = PymIFrameBlock(icon="code", label='Pym IFrame')
    iframe = IFrameBlock(icon="code", label='S3 IFrame')
    external_iframe = ExternalIFrame(icon="code", label="External Site IFrame")
    sidebar_pullquote = SidebarPullQuote()
    sidebar_note = SidebarNote()
    react_widget = SnippetChooserBlock(ReactWidget,
                                       icon="code",
                                       label="Javascript Widget")
class CMSStreamBlock(StreamBlock):
    # home = HomePageBlock(icon='grip', label='Homepage Block')

    h2 = CharBlock(icon='title', classname='title')
    h3 = CharBlock(icon='title', classname='title')
    h4 = CharBlock(icon='title', classname='title')
    h5 = CharBlock(icon='title', classname='title')

    intro = RichTextBlock(icon='pilcrow')
    paragraph = RichTextBlock(icon='pilcrow')
    pullquote = PullQuoteBlock(icon='openquote')

    image = ImageBlock(label='Aligned image', icon='image')
    document = DocumentChooserBlock(icon='doc-full-inverse')
    link = LinkBlock(icon='link')
    embed = EmbedBlock(icon='media')

    html = AlignedHTMLBlock(icon='code', label='Raw HTML')
Beispiel #27
0
class Stakeholders(StructBlock):
    block_heading = CharBlock(required=True)

    personas = ListBlock(
        StructBlock([
            ('image', ImageChooserBlock(required=True)),
            ('name', CharBlock(required=True)),
            ('position', CharBlock(required=True)),
            ('excerpt', TextBlock(required=True)),
        ]))

    file = DocumentChooserBlock(required=False)
    label = CharBlock(default="Find out more",
                      required=False,
                      label="Download button label")

    class Meta:
        image = 'pages/images/streamfield_blocks/team.jpg'
        template = 'pages/streamfield_blocks/stakeholders.html'
Beispiel #28
0
class BlogPage(Page):
	author = models.CharField(max_length = 250)
	date = models.DateField('Post date')
	intro = models.CharField(max_length = 250)
	tags = ClusterTaggableManager(through = BlogPageTag, blank = True)
	body = StreamField([
		('heading', blocks.CharBlock(classname = 'full title')),
		('paragraph', blocks.RichTextBlock()),
		('url', blocks.URLBlock()),
		('date', blocks.DateBlock()),
		('time', blocks.TimeBlock()),
		('page', blocks.PageChooserBlock()),
		('image', ImageChooserBlock()),
		('doc', DocumentChooserBlock()),
		('embed', EmbedBlock()),
	])

	def main_image(self):
		gallery_item = self.gallery_images.first()

		if gallery_item:
		    return gallery_item.image
		else:
		    return None

	search_fields = Page.search_fields + [
		index.SearchField('intro'),
		index.SearchField('body'),
		index.SearchField('author'),
	]

	content_panels = Page.content_panels + [
		MultiFieldPanel([
			FieldPanel('date'),
			FieldPanel('tags'),
			], heading = 'Blog information'),
		FieldPanel('author'),
		FieldPanel('intro'),
		StreamFieldPanel('body'),
		InlinePanel('gallery_images', label = 'Gallery images')
	]
Beispiel #29
0
class PDFBlock(blocks.StructBlock):
    """PDFBlock component"""
    doc = DocumentChooserBlock()
    title = blocks.CharBlock(required=False,
                             help_text='Override document title')

    def get_title(self, value):
        return value.get('title')

    def get_doc(self, value):
        return value.get(STREAM_DATA_DOC_FIELD)

    def get_searchable_content(self, value):
        return [self.get_title(value)]

    def get_api_representation(self, value, context=None):
        block_title = self.get_title(value)
        document = self.get_doc(value)

        if document:
            return {
                'doc_id': document.id,
                'title': block_title if block_title else document.title,
                'url': document.file.url,
                'span_id': get_span_id(PDF_BLOCK_TYPE, document.id),
            }

        log.warning(
            'Missing Document: document has been deleted but still referenced in page'
        )
        return {
            'doc_id': 0,
            'title': block_title if block_title else "Missing Document",
            'url': '',
            'span_id': 'missing-document',
        }
Beispiel #30
0
class DownloadLinkBlock(blocks.StructBlock):
    title = blocks.CharBlock(blank=True,default='')
    buttontext = blocks.CharBlock(blank=True,default='')
    link = DocumentChooserBlock()
    image = ImageChooserBlock()