class ReportingExamplePage(Page): """Page tempalte for "how to report" and "example scenario" pages Always within the Help section""" featured_image = models.ForeignKey('wagtailimages.Image', blank=True, null=True, on_delete=models.SET_NULL, related_name='+') pre_title = models.CharField(blank=True, null=True, max_length=255, choices=[ ('how', 'How to report'), ('scenario', 'Example scenario') ]) body = StreamField([ ('paragraph', blocks.RichTextBlock()), ('example_image', ExampleImage()), ('reporting_example_cards', ReportingExampleCards()) ], null=True) related_media_title = models.CharField(blank=True, null=True, max_length=255) related_media = StreamField([ ('continue_learning', blocks.ListBlock(ThumbnailBlock(), icon='doc-empty', template='blocks/related-media.html')), ], null=True) content_panels = Page.content_panels + [ FieldPanel('pre_title'), ImageChooserPanel('featured_image'), StreamFieldPanel('body'), FieldPanel('related_media_title'), StreamFieldPanel('related_media') ] @property def content_section(self): return 'help'
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)