class ResourcePage(Page): """Class for pages that include a side nav, multiple sections and citations""" intro = StreamField([('paragraph', blocks.RichTextBlock())], null=True) sections = StreamField([('sections', ResourceBlock())], null=True) citations = StreamField( [('citations', blocks.ListBlock(CitationsBlock()))], null=True) related_topics = StreamField( [('related_topics', blocks.ListBlock(blocks.PageChooserBlock(label="Related topic")))], null=True) breadcrumb_style = models.CharField(max_length=255, choices=[('primary', 'Blue'), ('secondary', 'Red')], default='primary') content_panels = Page.content_panels + [ StreamFieldPanel('intro'), StreamFieldPanel('sections'), StreamFieldPanel('citations'), StreamFieldPanel('related_topics') ] promote_panels = Page.promote_panels + [ FieldPanel('breadcrumb_style'), ]
class FullWidthPage(ContentPage): formatted_title = models.CharField( max_length=255, null=True, blank=True, default='', help_text= "Use if you need italics in the title. e.g. <em>Italicized words</em>") citations = StreamField( [('citations', blocks.ListBlock(CitationsBlock()))], null=True, blank=True) template = 'home/full_width_page.html' content_panels = ContentPage.content_panels + [ StreamFieldPanel('citations') ] promote_panels = Page.promote_panels search_fields = ContentPage.search_fields @property def content_section(self): return ''
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)
class ResourcePage(Page): # Class for pages that include a side nav, multiple sections and citations date = models.DateField(default=datetime.date.today) intro = StreamField([ ('paragraph', blocks.RichTextBlock()) ], null=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([ ('sections', ResourceBlock()) ], null=True) citations = StreamField([ ('citations', blocks.ListBlock(CitationsBlock())) ], null=True) related_topics = StreamField([ ('related_topics', blocks.ListBlock( blocks.PageChooserBlock(label="Related topic") )) ], null=True) category = models.CharField(max_length=255, choices=constants.report_child_categories.items(), help_text='If this is a report, add a category', blank=True, null=True) breadcrumb_style = models.CharField(max_length=255, choices=[('primary', 'Blue'), ('secondary', 'Red')], default='primary') show_contact_card = models.BooleanField( max_length=255, default=False, null=False, blank=False, choices=[ (True, 'Show contact card'), (False, 'Do not show contact card') ]) content_panels = Page.content_panels + [ StreamFieldPanel('intro'), FieldPanel('sidebar_title'), StreamFieldPanel('related_pages'), StreamFieldPanel('sections'), StreamFieldPanel('citations'), StreamFieldPanel('related_topics'), FieldPanel('show_contact_card') ] promote_panels = Page.promote_panels + [ FieldPanel('breadcrumb_style'), FieldPanel('category'), FieldPanel('date') ] # 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 display_date(self): return self.date.strftime('%B %Y') @property def content_section(self): return get_content_section(self)
class CustomPage(Page): """Flexible customizable page.""" author = models.CharField(max_length=255) date = models.DateField('Post date') body = StreamField([ ('heading', blocks.CharBlock(classname='full title')), ('paragraph', blocks.RichTextBlock()), ('html', blocks.RawHTMLBlock()), ('image', ImageChooserBlock()), ('table', TableBlock()), ('example_paragraph', ExampleParagraph()), ('example_forms', ExampleForms()), ('reporting_example_cards', ReportingExampleCards()) ]) sidebar = stream_factory(null=True, blank=True) citations = StreamField([('citations', blocks.ListBlock(CitationsBlock()))], null=True) record_articles = StreamField([ ('record_articles', blocks.ListBlock( blocks.PageChooserBlock(target_model=RecordPage) )) ], null=True) continue_learning = StreamField([ ('continue_learning', blocks.ListBlock(ThumbnailBlock(), icon='doc-empty')), ], null=True) show_contact_link = models.BooleanField( max_length=255, default=True, null=False, blank=False, choices=[ (True, 'Show contact link'), (False, 'Do not show contact link') ]) content_panels = Page.content_panels + [ FieldPanel('author'), FieldPanel('date'), StreamFieldPanel('body'), StreamFieldPanel('citations'), StreamFieldPanel('continue_learning'), MultiFieldPanel([ StreamFieldPanel('sidebar'), StreamFieldPanel('record_articles'), FieldPanel('show_contact_link'), ], heading="Sidebar", classname="collapsible" ) ] # 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)
class CustomPage(Page): """Flexible customizable page.""" author = models.CharField(max_length=255) date = models.DateField('Creation date') body = StreamField([ ('heading', blocks.CharBlock(classname='full title')), ('paragraph', blocks.RichTextBlock()), ('html', blocks.RawHTMLBlock()), ('example_image', ExampleImage()), ('image', ImageChooserBlock()), ('table', TableBlock(table_options=core_table_options)), ('example_paragraph', ExampleParagraph()), ('example_forms', ExampleForms()), ('reporting_example_cards', ReportingExampleCards()), ('contact_info', ContactInfoBlock()), ('internal_button', InternalButtonBlock()), ('external_button', ExternalButtonBlock()), ('contribution_limits_table', SnippetChooserBlock('home.EmbedTableSnippet', template='blocks/embed-table.html', icon='table')), ], null=True) sidebar = stream_factory(null=True, blank=True) related_topics = StreamField( [('related_topics', blocks.ListBlock(blocks.PageChooserBlock(label="Related topic")))], null=True, blank=True) citations = StreamField( [('citations', blocks.ListBlock(CitationsBlock()))], null=True, blank=True) record_articles = StreamField( [('record_articles', blocks.ListBlock(blocks.PageChooserBlock(target_model=RecordPage)))], null=True, blank=True) continue_learning = StreamField([ ('continue_learning', blocks.ListBlock(ThumbnailBlock(), icon='doc-empty')), ], null=True, blank=True) show_contact_link = models.BooleanField(max_length=255, default=True, null=False, blank=False, choices=[ (True, 'Show contact link'), (False, 'Do not show contact link') ]) content_panels = Page.content_panels + [ FieldPanel('author'), FieldPanel('date'), StreamFieldPanel('body'), StreamFieldPanel('related_topics'), StreamFieldPanel('citations'), StreamFieldPanel('continue_learning'), MultiFieldPanel([ StreamFieldPanel('sidebar'), StreamFieldPanel('record_articles'), FieldPanel('show_contact_link'), ], heading="Sidebar", classname="collapsible") ] # Adds a settings choice-field for conditionally adding a JS script to a CustomPage conditional_js = models.CharField( max_length=255, choices=constants.conditional_js.items(), blank=True, null=True, help_text='Choose a JS script to add only to this page') # 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'), FieldPanel('conditional_js') ] 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)