Esempio n. 1
0
class SimplePageWithMenuSidebar(BaseSidebarPageMixin, Page):
    body = StreamField([
        ('text', StyledTextBlock(label='Text')),
        ('image', AlignedImageBlock()),
        ('raw_html', blocks.RawHTMLBlock()),
        ('blockquote', RichTextBlockQuoteBlock()),
        ('list',
         blocks.ListBlock(blocks.CharBlock(label="List Item"),
                          template='common/blocks/list_block_columns.html')),
        ('video', AlignedEmbedBlock()),
        ('heading_1', Heading1()),
        ('heading_2', Heading2()),
        ('heading_3', Heading3()),
    ])

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
    ]

    settings_panels = Page.settings_panels + BaseSidebarPageMixin.settings_panels

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

    def get_meta_description(self):
        if self.search_description:
            return self.search_description

        return truncatewords(strip_tags(self.body.render_as_block()), 20)
Esempio n. 2
0
class FAQPage(MetadataPageMixin, BaseSidebarPageMixin, Page):
    subtitle = models.CharField(max_length=255, null=True, blank=True)
    body = StreamField(
        [
            ('text', blocks.RichTextBlock()),
            ('image', AlignedImageBlock()),
            ('raw_html', blocks.RawHTMLBlock()),
            ('blockquote', RichTextBlockQuoteBlock()),
            ('list', blocks.ListBlock(
                blocks.CharBlock(label="List Item"),
                template='common/blocks/list_block_columns.html'
            )),
            ('video', AlignedEmbedBlock()),
            ('heading_1', Heading1()),
            ('heading_2', Heading2()),
            ('heading_3', Heading3()),
        ],
        blank=True,
        null=True
    )

    content_panels = Page.content_panels + [
        FieldPanel('subtitle'),
        StreamFieldPanel('body'),
        InlinePanel('questions', label="Questions")
    ]

    settings_panels = Page.settings_panels + BaseSidebarPageMixin.settings_panels
Esempio n. 3
0
class SimplePageWithMenuSidebar(MetadataPageMixin, BaseSidebarPageMixin, Page):
    subtitle = models.CharField(max_length=255, null=True, blank=True)
    body = StreamField([
        ('text',
         blocks.RichTextBlock(features=[
             'bold',
             'italic',
             'h2',
             'h3',
             'h4',
             'ol',
             'ul',
             'hr',
             'embed',
             'link',
             'document-link',
             'image',
             'code',
         ], )),
        ('image', AlignedImageBlock()),
        ('raw_html', blocks.RawHTMLBlock()),
        ('blockquote', RichTextBlockQuoteBlock()),
        ('list',
         blocks.ListBlock(blocks.CharBlock(label="List Item"),
                          template='common/blocks/list_block_columns.html')),
        ('video', AlignedEmbedBlock()),
        ('heading_1', Heading1()),
        ('heading_2', Heading2()),
        ('heading_3', Heading3()),
    ],
                       blank=False)

    content_panels = Page.content_panels + [
        FieldPanel('subtitle'),
        StreamFieldPanel('body'),
    ]

    settings_panels = Page.settings_panels + BaseSidebarPageMixin.settings_panels

    search_fields_pgsql = ['title', 'body']

    def get_search_content(self):
        return get_search_content_by_fields(self, self.search_fields_pgsql)

    def get_meta_description(self):
        if self.search_description:
            return self.search_description

        return truncatewords(strip_tags(self.body.render_as_block()), 20)
Esempio n. 4
0
class SimplePage(Page):
    body = StreamField([
        ('text',
         StyledTextBlock(
             label='Text',
             template='common/blocks/styled_text_full_bleed.html')),
        ('image', AlignedImageBlock()),
        ('raw_html', blocks.RawHTMLBlock()),
        ('blockquote', RichTextBlockQuoteBlock()),
        ('list',
         blocks.ListBlock(blocks.CharBlock(label="List Item"),
                          template='common/blocks/list_block_columns.html')),
        ('video', AlignedEmbedBlock()),
        ('heading_1', Heading1()),
        ('heading_2', Heading2()),
        ('heading_3', Heading3()),
    ])

    sidebar_content = StreamField([
        ('heading', Heading2()),
        ('rich_text', blocks.RichTextBlock()),
    ],
                                  default=None)

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
        StreamFieldPanel('sidebar_content')
    ]

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

    def get_meta_description(self):
        if self.search_description:
            return self.search_description

        return truncatewords(strip_tags(self.body.render_as_block()), 20)
Esempio n. 5
0
class MarketingIndexPage(MetadataPageMixin, Page):
    subtitle = models.CharField(
        max_length=255,
        null=True,
        blank=True,
        help_text="Appears immediately below page title.")
    body = StreamField([
        ('text', blocks.RichTextBlock()),
        ('image', AlignedImageBlock()),
        ('raw_html', blocks.RawHTMLBlock()),
        ('blockquote', RichTextBlockQuoteBlock()),
        ('list',
         blocks.ListBlock(blocks.CharBlock(label="List Item"),
                          template='common/blocks/list_block_columns.html')),
        ('video', AlignedEmbedBlock()),
        ('heading_1', Heading1()),
        ('heading_2', Heading2()),
        ('heading_3', Heading3()),
    ],
                       null=True,
                       blank=True)

    subheader = models.CharField(
        max_length=255,
        default="How to install SecureDrop at your organization.",
        help_text="Displayed below features.")

    how_to_install_subtitle = models.CharField(
        max_length=255,
        null=True,
        blank=True,
        help_text="Appears immediately below subheader.")

    how_to_install_body = StreamField([
        ('text', blocks.RichTextBlock()),
        ('image', AlignedImageBlock()),
        ('raw_html', blocks.RawHTMLBlock()),
        ('blockquote', RichTextBlockQuoteBlock()),
        ('list',
         blocks.ListBlock(blocks.CharBlock(label="List Item"),
                          template='common/blocks/list_block_columns.html')),
        ('video', AlignedEmbedBlock()),
        ('heading_1', Heading1()),
        ('heading_2', Heading2()),
        ('heading_3', Heading3()),
    ],
                                      null=True,
                                      blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('subtitle'),
        StreamFieldPanel('body'),
        InlinePanel('features', label="Features"),
        MultiFieldPanel(heading='How to install',
                        children=[
                            FieldPanel('subheader'),
                            FieldPanel('how_to_install_subtitle'),
                            StreamFieldPanel('how_to_install_body'),
                        ]),
    ]

    subpage_types = ['marketing.FeaturePage']

    search_fields_pgsql = ['title', 'body', 'subheader']

    def get_search_content(self):
        search_elements = get_search_content_by_fields(
            self, self.search_fields_pgsql)

        for feature in self.features.all():
            search_elements.append(feature.feature.title)
            search_elements.append(feature.feature.teaser_title)
            search_elements.append(feature.feature.teaser_description)

        return search_elements
Esempio n. 6
0
class BlogPage(MetadataPageMixin, Page):
    publication_datetime = models.DateTimeField(
        help_text='Past or future date of publication')

    body = StreamField([
        ('text', blocks.RichTextBlock()),
        ('code', CodeBlock(label='Code Block')),
        ('image', AlignedImageBlock()),
        ('raw_html', blocks.RawHTMLBlock()),
        ('blockquote', RichTextBlockQuoteBlock()),
        ('list',
         blocks.ListBlock(blocks.CharBlock(label="List Item"),
                          template='common/blocks/list_block_columns.html')),
        ('video', AlignedEmbedBlock()),
        ('heading_1', Heading1()),
        ('heading_2', Heading2()),
        ('heading_3', Heading3()),
    ],
                       blank=False)

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

    category = models.ForeignKey(
        # Likely a CategoryPage
        'wagtailcore.Page',
        on_delete=models.PROTECT,
        related_name='+',
    )

    release = models.OneToOneField(
        'github.Release',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='blog_page',
        help_text=
        'Releases can be associated with only one post, which should be a release announcement.'
    )

    content_panels = Page.content_panels + [
        FieldPanel('publication_datetime'),
        StreamFieldPanel('body'),
        MultiFieldPanel(heading='Teaser',
                        children=[
                            FieldPanel('teaser_text'),
                        ]),
        PageChooserPanel('category', 'blog.CategoryPage'),
        FieldPanel('release'),
    ]

    parent_page_types = ['blog.BlogIndexPage']

    search_fields_pgsql = ['title', 'body', 'teaser_text', 'category']

    class Meta:
        indexes = [
            models.Index(fields=['publication_datetime']),
            models.Index(fields=['category']),
        ]

    def get_meta_description(self):
        if self.teaser_text:
            return strip_tags(self.teaser_text)

        if self.search_description:
            return self.search_description

        return truncatewords(strip_tags(self.body.render_as_block()), 20)

    def get_search_content(self):
        return get_search_content_by_fields(self, self.search_fields_pgsql)