class LegacyBlogPage(AbstractFilterPage): content = StreamField([ ('content', blocks.RawHTMLBlock(help_text='Content from WordPress unescaped.')), ]) objects = CFGOVPageManager() content_panels = AbstractFilterPage.content_panels + [ StreamFieldPanel('header'), StreamFieldPanel('content'), ] edit_handler = TabbedInterface([ ObjectList(content_panels, heading='General Content'), ObjectList(AbstractFilterPage.sidefoot_panels, heading='Sidebar'), ObjectList(AbstractFilterPage.settings_panels, heading='Configuration'), ]) template = 'blog/blog_page.html'
class DemoPage(Page): body = StreamField([ ('footer', FooterChooserBlock(Footer)), ('full_width_feature', FullWidthFeatureBlock()) ]) content_panels = Page.content_panels + [ StreamFieldPanel('body'), ] template = 'demo/demo_page.jinja'
class BrowseFilterablePage(FilterableFeedPageMixin, FilterableListMixin, CFGOVPage): header = StreamField([ ('text_introduction', molecules.TextIntroduction()), ('featured_content', organisms.FeaturedContent()), ]) content = StreamField(BrowseFilterableContent) secondary_nav_exclude_sibling_pages = models.BooleanField(default=False) # General content tab content_panels = CFGOVPage.content_panels + [ StreamFieldPanel('header'), StreamFieldPanel('content'), ] sidefoot_panels = CFGOVPage.sidefoot_panels + [ FieldPanel('secondary_nav_exclude_sibling_pages'), ] # Tab handler interface edit_handler = TabbedInterface([ ObjectList(content_panels, heading='General Content'), ObjectList(sidefoot_panels, heading='SideFoot'), ObjectList(CFGOVPage.settings_panels, heading='Configuration'), ]) template = 'browse-filterable/index.html' objects = PageManager() search_fields = CFGOVPage.search_fields + [ index.SearchField('content'), index.SearchField('header') ] @property def page_js(self): return ( super(BrowseFilterablePage, self).page_js + ['secondary-navigation.js'] )
class VenuePage(CustomPage): """Page for venue and hotel information.""" background_image = models.ForeignKey( "wagtailimages.Image", blank=True, null=True, help_text="Maximum file size is 10 MB", on_delete=models.SET_NULL, related_name="+") venue_info_section = StreamField(HTMLBlock()) google_maps_url = models.URLField(blank=True, max_length=2083) hotel_info_section = StreamField(HTMLBlock()) content_panels = Page.content_panels + [ FieldPanel("background_image"), StreamFieldPanel("venue_info_section"), FieldPanel("google_maps_url"), StreamFieldPanel("hotel_info_section"), ]
class InlineStreamPageSection(Orderable): page = ParentalKey('tests.InlineStreamPage', related_name='sections', on_delete=models.CASCADE) body = StreamField([ ('text', CharBlock()), ('rich_text', RichTextBlock()), ('image', ImageChooserBlock()), ]) panels = [StreamFieldPanel('body')]
class StaticPage(Page): body = StreamField(BodyStreamBlock()) search_fields = Page.search_fields + [ index.SearchField('body'), ] content_panels = Page.content_panels + [ StreamFieldPanel('body'), ]
class StreamPage(Page): """just a testing page""" body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ]) content_panels = Page.content_panels + [ StreamFieldPanel('body') ]
class LegacyBlogPage(AbstractFilterPage): content = StreamField([ ('content', blocks.RawHTMLBlock(help_text='Content from WordPress unescaped.')), ('feedback', v1_blocks.Feedback()), ]) objects = CFGOVPageManager() edit_handler = AbstractFilterPage.generate_edit_handler( content_panel=StreamFieldPanel('content')) template = 'blog/blog_page.html'
class PosterItemPage(ProgrammeItemPage): content = StreamField([ ('contribution', PosterContributionBlock()), ], null=True, blank=True) content_panels = ProgrammeItemPage.content_panels + [ StreamFieldPanel('content'), ]
class NavMenu(models.Model): _nav_category_block = NavCategoryBlock() name = models.CharField( max_length=50, choices=NAV_MENU_CHOICES, unique=True) menu = StreamField([ ('nav_category', _nav_category_block), ] + nav_content) panels = [ FieldPanel('name'), StreamFieldPanel('menu'), ] def __str__(self): return self.name def stream_field_to_json(self, stream_field): """ Recursive function to turn the menu stream field into json """ row = {} row['type'] = stream_field.block_type if hasattr(stream_field.block, 'get_serializable_data'): row['value'] = stream_field.block.get_serializable_data( stream_field.value) else: row['value'] = stream_field.value if row['type'] == "image" and row['value']: image = row['value'] row['value'] = { "id": image.pk, "title": image.title, "url": image.file.url, } elif row['type'] == "nav_category": sub_nav = [] for sub_stream_field in stream_field.value['sub_nav']: sub_nav.append(self.stream_field_to_json(sub_stream_field)) row['value']['sub_nav'] = sub_nav return row def to_json(self): """ JSON representation of menu stream field """ result = [] for stream_field in self.menu: result.append(self.stream_field_to_json(stream_field)) return json.dumps(result, default=date_handler) def set_category_template(self, category_template): self._nav_category_block.set_template(category_template) def set_link_template(self, link_template): for content_type in nav_content: if hasattr(content_type[1].meta, 'template'): content_type[1].meta.template = link_template
class AnswerLandingPage(LandingPage): """ Page type for Ask CFPB's landing page. """ content_panels = [ StreamFieldPanel('header') ] edit_handler = TabbedInterface([ ObjectList(content_panels, heading='Content'), ObjectList(LandingPage.settings_panels, heading='Configuration'), ]) template = 'ask-cfpb/landing-page.html' objects = CFGOVPageManager() def get_portal_cards(self): """Return an array of dictionaries used to populate portal cards.""" portal_cards = [] portal_pages = SublandingPage.objects.filter( portal_topic_id__isnull=False, language=self.language, ).order_by('portal_topic__heading') for portal_page in portal_pages: topic = portal_page.portal_topic # Only include a portal if it has featured answers featured_answers = topic.featured_answers(self.language) if not featured_answers: continue # If the portal page is live, link to it if portal_page.live: url = portal_page.url # Otherwise, link to the topic "see all" page if there is one else: topic_page = topic.portal_search_pages.filter( language=self.language, live=True).first() if topic_page: url = topic_page.url else: continue # pragma: no cover portal_cards.append({ 'topic': topic, 'title': topic.title(self.language), 'url': url, 'featured_answers': featured_answers, }) return portal_cards def get_context(self, request, *args, **kwargs): context = super(AnswerLandingPage, self).get_context(request) context['portal_cards'] = self.get_portal_cards() context['about_us'] = get_standard_text(self.language, 'about_us') context['disclaimer'] = get_standard_text(self.language, 'disclaimer') return context
class BreadPage(Page): """ Detail view for a specific bread """ introduction = models.TextField(help_text='Text to describe the page', blank=True) image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', help_text= 'Landscape mode only; horizontal width between 1000px and 3000px.') body = StreamField(BaseStreamBlock(), verbose_name="Page body", blank=True) origin = models.ForeignKey( Country, on_delete=models.SET_NULL, null=True, blank=True, ) # We include related_name='+' to avoid name collisions on relationships. # e.g. there are two FooPage models in two different apps, # and they both have a FK to bread_type, they'll both try to create a # relationship called `foopage_objects` that will throw a valueError on # collision. bread_type = models.ForeignKey('breads.BreadType', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') ingredients = ParentalManyToManyField('BreadIngredient', blank=True) content_panels = Page.content_panels + [ FieldPanel('introduction', classname="full"), ImageChooserPanel('image'), StreamFieldPanel('body'), FieldPanel('origin'), FieldPanel('bread_type'), MultiFieldPanel([ FieldPanel( 'ingredients', widget=forms.CheckboxSelectMultiple, ), ], heading="Additional Metadata", classname="collapsible collapsed"), ] search_fields = Page.search_fields + [ index.SearchField('body'), ] parent_page_types = ['BreadsIndexPage']
class HomePage(CFGOVPage): header = StreamField([ ('info_unit', molecules.InfoUnit()), ('half_width_link_blob', molecules.HalfWidthLinkBlob()), ], blank=True) latest_updates = StreamField([ ('posts', blocks.ListBlock(blocks.StructBlock([ ('categories', blocks.ChoiceBlock(choices=ref.limited_categories, required=False)), ('link', atoms.Hyperlink()), ('date', blocks.DateTimeBlock(required=False)), ]))), ], blank=True) # General content tab content_panels = CFGOVPage.content_panels + [ StreamFieldPanel('header'), StreamFieldPanel('latest_updates'), ] # Tab handler interface edit_handler = TabbedInterface([ ObjectList(content_panels, heading='General Content'), ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'), ObjectList(CFGOVPage.settings_panels, heading='Configuration'), ]) # Sets page to only be createable at the root parent_page_types = ['wagtailcore.Page'] template = 'index.html' objects = PageManager() def get_category_name(self, category_icon_name): cats = dict(ref.limited_categories) return cats[str(category_icon_name)] def get_context(self, request): context = super(HomePage, self).get_context(request) return context
class HowWeWorkPage(Page): header_text = models.CharField(max_length=255) header_image = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') how_we_work_intro = RichTextField() what_we_do_title = models.CharField(max_length=255) what_we_do_image = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') what_we_do_content = StreamField([('what_we_do_content', blocks.StreamBlock([ ('image', ImageChooserBlock()), ('title', blocks.RichTextBlock()), ('description', blocks.RichTextBlock()), ]))]) the_process_title = RichTextField() the_process_content = StreamField([ ('process_content', blocks.StructBlock([('title', blocks.CharBlock()), ('icon_classes', blocks.CharBlock()), ('description', blocks.RichTextBlock())], template='streams/process_content.html')) ]) content_panels = Page.content_panels + [ FieldPanel('header_text'), ImageChooserPanel('header_image'), FieldPanel('how_we_work_intro'), FieldPanel('what_we_do_title'), ImageChooserPanel('what_we_do_image'), StreamFieldPanel('what_we_do_content'), FieldPanel('the_process_title'), StreamFieldPanel('the_process_content'), ]
class WebPage(Page): # ---- General Page information ------ title_sv = models.CharField(max_length=255) translated_title = TranslatedField('title', 'title_sv') body_en = StreamField( WAGTAIL_STATIC_BLOCKTYPES + [ ('contact_card', ContactCardBlock()), ('google_calendar', GoogleCalendarBlock()), ('google_drive', GoogleDriveBlock()), ('google_form', GoogleFormBlock()), ('news', LatestNewsBlock()), ], blank=True, ) body_sv = StreamField( WAGTAIL_STATIC_BLOCKTYPES + [ ('contact_card', ContactCardBlock()), ('google_calendar', GoogleCalendarBlock()), ('google_drive', GoogleDriveBlock()), ('google_form', GoogleFormBlock()), ('news', LatestNewsBlock()), ], blank=True, ) body = TranslatedField('body_en', 'body_sv') content_panels_en = Page.content_panels + [ StreamFieldPanel('body_en'), ] content_panels_sv = [ FieldPanel('title_sv', classname="full title"), StreamFieldPanel('body_sv'), ] edit_handler = TabbedInterface([ ObjectList(content_panels_en, heading=_('English')), ObjectList(content_panels_sv, heading=_('Swedish')), ObjectList(Page.promote_panels, heading=_('Promote')), ObjectList(Page.settings_panels, heading=_('Settings')), ])
class GalleriesPage(Page): body = StreamField([ ('image', ListBlock(ImageBlock(), template='blocks/galleries.html')), ], blank=True, null=True) content_panels = Page.content_panels + [StreamFieldPanel('body')] template = 'home/default_page.html' parent_page_types = ['EventListPage'] subpage_types = []
class Region(Page): region = models.ForeignKey(DataRegion, null=True, blank=True, on_delete=models.SET_NULL) body = NoWrapsStreamField(CONTENT_BLOCKS + DATA_BLOCKS + COLUMN_BLOCKS) content_panels = Page.content_panels + [ FieldPanel('region'), StreamFieldPanel('body') ] parent_page_types = ['wagtailcms.RegionIndex']
def generate_edit_handler(self, content_panel): content_panels = [ StreamFieldPanel('header'), content_panel, ] return TabbedInterface([ ObjectList(self.content_panels + content_panels, heading='General Content'), ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'), ObjectList(self.settings_panels, heading='Configuration'), ])
class Header(BaseSetting): links = StreamField([ ('links', StructBlock([ ('link', PageChooserBlock(required=True)), ('text', CharBlock(max_length=255)), ], blank=True, null=True)) ], null=True) panels = [ StreamFieldPanel('links') ]
class HomePageSection(Page): main_image = models.ForeignKey(CustomImage, null=True, blank=True, on_delete=models.SET_NULL, related_name='+') orientation = models.CharField(max_length=50, choices=(('left', 'LEFT'), ('right', 'RIGHT'), ('centre', 'CENTRE'), ('freeform', 'FREEFORM')), default='left') link_page = models.ForeignKey('wagtailcore.Page', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') button_text = models.CharField(max_length=255, help_text="Button title", null=True, blank=True, default="button") sectionClassName = models.SlugField(max_length=100, help_text="no spaces", default="homepage-section") body = RichTextField(blank=True) streamBody = StreamField([ ('heading', blocks.CharBlock(classname="full-title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('markup', RawHTMLBlock()), ], null=True, blank=True) sectionBackgroundSelector = models.ForeignKey('wagtaildocs.Document', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') content_panels = Page.content_panels + [ FieldPanel('orientation'), FieldPanel('sectionClassName'), MultiFieldPanel(IndexLink.panels, "Related index page"), ImageChooserPanel('main_image'), DocumentChooserPanel('sectionBackgroundSelector'), FieldPanel('body', classname="section-body"), StreamFieldPanel('streamBody'), InlinePanel('related_links', label="Section link items"), ] def get_context(self, request): context = super(HomePageSection, self).get_context(request) return context
class BlogPage(AbstractFilterPage): content = StreamField([ ('full_width_text', organisms.FullWidthText()), ('image_text_50_50_group', organisms.ImageText5050Group()), ('feedback', v1_blocks.Feedback()), ]) edit_handler = AbstractFilterPage.generate_edit_handler( content_panel=StreamFieldPanel('content')) template = 'blog/blog_page.html' objects = PageManager()
class UserRolePage(RelativeURLMixin, Page): user_role = models.OneToOneField(UserRole, on_delete=models.PROTECT) body = StreamField([ ('paragraph', blocks.RichTextBlock()), ]) content_panels = Page.content_panels + [ FieldPanel('user_role'), StreamFieldPanel('body'), ] parent_page_types = ['UserRoleIndex']
class HomePage(Page): body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('embed', EmbedBlock()) ]) content_panels = Page.content_panels + [ StreamFieldPanel('body'), ]
class HomePage(Page): slideshow = StreamField([('Image', CaptionedImageBlock())], blank=True) about_us = RichTextField(blank=True) tagline = models.CharField(max_length=200, blank=True) vision = RichTextField(blank=True) facebook = models.CharField(max_length=200, default='') googleplus = models.CharField(blank=True, max_length=200) twitter = models.CharField(blank=True, max_length=200) youtube = models.CharField(blank=True, max_length=200) email = models.CharField(max_length=200, default='') feed_image = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('facebook'), FieldPanel('googleplus'), FieldPanel('twitter'), FieldPanel('youtube'), FieldPanel('email'), ], heading='Contact Links'), StreamFieldPanel('slideshow'), FieldPanel('about_us'), FieldPanel('tagline'), FieldPanel('vision'), ] promote_panels = [ MultiFieldPanel(Page.promote_panels, "Common page configuration"), ImageChooserPanel('feed_image'), ] subpage_types = [ 'club_home.ClubHomePage', 'story.StoryTagIndexPage', 'events.EventIndexPage' ] def get_context(self, request): # Update context to include only published posts, ordered by reverse-chron context = super(HomePage, self).get_context(request) aevent = Events.objects.filter(Q(is_active=1)).order_by('start')[:6] context['aevent'] = aevent return context
class ApplicationForm(models.Model): name = models.CharField(max_length=255) form_fields = StreamField(CustomFormFieldsBlock()) panels = [ FieldPanel('name'), StreamFieldPanel('form_fields'), ] def __str__(self): return self.name
class DefaultStreamPage(Page): body = StreamField([ ('text', CharBlock()), ('rich_text', RichTextBlock()), ('image', ImageChooserBlock()), ], default='') content_panels = [ FieldPanel('title'), StreamFieldPanel('body'), ]
class HomePage(Page): button = models.CharField(max_length=255) body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ]) content_panels = Page.content_panels + [ FieldPanel('button'), StreamFieldPanel('body') ]
class BlogPage(Page): intro = RichTextField("Intro (used only for blog index listing)", blank=True) body = RichTextField("body (deprecated. Use streamfield instead)", blank=True) streamfield = StreamField(StoryBlock()) author_left = models.CharField(max_length=255, blank=True, help_text='author who has left Torchbox') date = models.DateField("Post date") feed_image = models.ForeignKey('torchbox.TorchboxImage', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') marketing_only = models.BooleanField( default=False, help_text='Display this blog post only on marketing landing page') search_fields = Page.search_fields + (index.SearchField('body'), ) @property def blog_index(self): # Find blog index in ancestors for ancestor in reversed(self.get_ancestors()): if isinstance(ancestor.specific, BlogIndexPage): return ancestor # No ancestors are blog indexes, # just return first blog index in database return BlogIndexPage.objects.first() @property def has_authors(self): for author in self.related_author.all(): if author.author: return True content_panels = [ FieldPanel('title', classname="full title"), InlinePanel('related_author', label="Author"), FieldPanel('author_left'), FieldPanel('date'), FieldPanel('intro', classname="full"), FieldPanel('body', classname="full"), StreamFieldPanel('streamfield'), InlinePanel('related_links', label="Related links"), InlinePanel('tags', label="Tags") ] promote_panels = [ MultiFieldPanel(Page.promote_panels, "Common page configuration"), ImageChooserPanel('feed_image'), FieldPanel('marketing_only'), ]
class LinkedContentPage(RelativeURLMixin, Page): body = StreamField(content_blocks) content_panels = Page.content_panels + [ InlinePanel('roles', label=_("Roles")), InlinePanel('links', label=_("Links")), StreamFieldPanel('body'), ] search_fields = Page.search_fields + [ index.SearchField('body'), ]
class Footer(models.Model): name = models.CharField(max_length=256) contents = StreamField(FOOTER_BLOCKS) panels = [ FieldPanel('name'), StreamFieldPanel('contents'), ] def __str__(self): return self.name