class ContactPage(Page): contact_items = StreamField([('contact_items', ContactInfoBlock())]) services_title = models.TextField() services = StreamField([('services', blocks.RichTextBlock())]) content_panels = Page.content_panels + [ StreamFieldPanel('contact_items'), FieldPanel('services_title'), StreamFieldPanel('services'), ]
class ContactPage(Page): contact_items = StreamField([('contact_items', ContactInfoBlock())]) services_title = models.TextField() services = StreamField([('services', blocks.RichTextBlock())]) content_panels = Page.content_panels + [ StreamFieldPanel('contact_items'), FieldPanel('services_title'), StreamFieldPanel('services'), ] @property def content_section(self): return 'about'
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)
logger = logging.getLogger(__name__) """options for wagtail default table_block """ core_table_options = { 'renderer': 'html', } stream_factory = functools.partial( StreamField, [ ('heading', blocks.CharBlock(classname='full title')), ('paragraph', blocks.RichTextBlock()), ('html', blocks.RawHTMLBlock()), ('image', ImageChooserBlock()), ('table', TableBlock(table_options=core_table_options)), ('custom_table', CustomTableBlock()), ('contact', ContactInfoBlock()), ('internal_button', InternalButtonBlock()), ('external_button', ExternalButtonBlock()), ], ) def get_content_section(page): """ Find the top-level parent in order to highlight the main nav item and set social images. Takes a Page object and returns a string of either 'legal', 'help', or '' """ slugs = { 'help-candidates-and-committees': 'help', 'legal-resources': 'legal',