Beispiel #1
0
class CollectionPage(Page):
    body = stream_factory(null=True, blank=True)
    sidebar_title = models.CharField(max_length=255, null=True, blank=True)

    related_pages = StreamField(
        [('related_pages', blocks.ListBlock(blocks.PageChooserBlock()))],
        null=True,
        blank=True)
    sections = StreamField([('section', CollectionBlock())])
    show_search = models.BooleanField(max_length=255,
                                      default=False,
                                      null=False,
                                      blank=False,
                                      choices=[
                                          (True, 'Show committee search box'),
                                          (False,
                                           'Do not show committee search box')
                                      ])
    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
        FieldPanel('sidebar_title'),
        FieldPanel('show_search'),
        StreamFieldPanel('related_pages'),
        StreamFieldPanel('sections'),
    ]
Beispiel #2
0
class CollectionPage(Page):
    body = stream_factory(null=True, blank=True)
    sidebar_title = models.CharField(max_length=255, null=True, blank=True)

    related_pages = StreamField(
        [('related_pages', blocks.ListBlock(blocks.PageChooserBlock()))],
        null=True,
        blank=True)
    sections = StreamField([('section', CollectionBlock())])

    reporting_examples = StreamField(
        [('reporting_examples', blocks.ListBlock(CitationsBlock()))],
        null=True,
        blank=True)

    show_search = models.BooleanField(max_length=255,
                                      default=False,
                                      null=False,
                                      blank=False,
                                      choices=[
                                          (True, 'Show committee search box'),
                                          (False,
                                           'Do not show committee search box')
                                      ])
    show_contact_card = models.BooleanField(max_length=255,
                                            default=True,
                                            null=False,
                                            blank=False,
                                            choices=[
                                                (True, 'Show contact card'),
                                                (False,
                                                 'Do not show contact card')
                                            ])
    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
        FieldPanel('sidebar_title'),
        FieldPanel('show_search'),
        FieldPanel('show_contact_card'),
        StreamFieldPanel('related_pages'),
        StreamFieldPanel('sections'),
        StreamFieldPanel('reporting_examples')
    ]

    # Adds a settings field for making a custom title that displays in the Wagtail page explorer
    menu_title = models.CharField(max_length=255, null=True)
    settings_panels = Page.settings_panels + [FieldPanel('menu_title')]

    def get_admin_display_title(self):
        return self.menu_title if self.menu_title else self.title

    @property
    def content_section(self):
        return get_content_section(self)