class HomeFlexPage(Page): template = 'home/home_page.html' content = StreamField( [ ('title_and_text', blocks.TitleAndTextBlock()), ('full_richtext', blocks.RichTextBlock()), ('simple_richtext', blocks.SimpleRichTextBlock()), ('service_cards', blocks.CardBlock()), ], null=True, blank=True ) subtitle = models.CharField(max_length=150, null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel('subtitle'), StreamFieldPanel('content'), ] class Meta: verbose_name = 'Flexed Home Page' verbose_name_plural = 'Flexed Home Pages'
class FlexPage(Page): # @remember: # This page generates the blocks/streamfields on the your flex_page.html. # Copy/Paste this whole class to make other pages flexibe, # Change the template. template = 'flex/flex_page.html' # @remember: # This is the content being rendered on the flex_page.html content = StreamField( [ ('title_and_text', blocks.TitleAndTextBlock()), ('full_richtext', blocks.RichTextBlock()), ('simple_richtext', blocks.SimpleRichTextBlock()), ('service_cards', blocks.CardBlock()), ], null=True, blank=True ) subtitle = models.CharField(max_length=150, null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel('subtitle'), StreamFieldPanel('content'), ] class Meta: verbose_name = 'Flex Page' verbose_name_plural = 'Flex Pages'
class ProjectDetailPage(Page): """Project Detail Page""" custom_title = models.CharField( max_length=100, blank=False, null=False, help_text='Overwrites the default content.') project_image = models.ForeignKey("wagtailimages.Image", blank=False, null=True, related_name="+", on_delete=models.SET_NULL) content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("full_richtext", blocks.RichTextBlock()), ("cards", blocks.CardBlock()), ], null=True, blank=True, ) categories = ParentalManyToManyField("project.ProjectCategory", blank=True) content_panels = Page.content_panels + [ FieldPanel("custom_title"), ImageChooserPanel("project_image"), MultiFieldPanel( [FieldPanel("categories", widget=forms.CheckboxSelectMultiple)], heading="Categories"), StreamFieldPanel("content"), ]
class BlogDetailPage(Page): """Blog detail page.""" template = "blog/blog_detail_page.html" custom_title = models.CharField(max_length=100, blank=False, null=False, help_text="Overwrites the default title.") blog_image = models.ForeignKey("wagtailimages.Image", blank=False, null=True, related_name="+", on_delete=models.SET_NULL) content = StreamField([ ("title_and_text", blocks.TitleAndTextBlock()), ("full_rich_text", blocks.RichTextBlock()), ("simple_richtext", blocks.SimpleRichTextBlock()), ("cards", blocks.CardBlock()), ("call_to_action", blocks.CTABlock()), ], null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel('custom_title'), ImageChooserPanel('blog_image'), StreamFieldPanel("content") ]
class FlexPage(Page): """flexbile page class""" template = "flex/flex_page.html" parent_page_types = ['flex.FlexPage', 'home.HomePage'] subpage_types = ['flex.FlexPage'] subtitle = models.CharField(max_length=100, null=True, blank=True) content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("full_richtext", blocks.RichTextBlock()), ("simple_richtext", blocks.SimpleRichTextBlock()), # ("simple_richtext", blocks.SimpleRichTextBlock(features=["bold", "italic"])), ("cards", blocks.CardBlock()), ("cta", blocks.CTABlock()), ("button", blocks.ButtonBlock()), ], null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel("subtitle"), StreamFieldPanel("content"), ] class Meta: # noqa verbose_name = "Flex Page" verbose_name_plural = "Flex Pages"
class FlexPage(Page): """Fleixble Page Class""" template = "flex/flex_page.html" content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("full_richtext", blocks.RichTextBlock()), ("simple_richtext", blocks.SimpleRichTextBlock()), ("cards", blocks.CardBlock()), ("cta", blocks.CTABlock()), ("button", blocks.ButtonBlock()), ], null=True, blank=True, ) subtitle = models.CharField(max_length=100, null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel("subtitle"), StreamFieldPanel("content"), ] class Meta: # noqa verbose_name = "Flex Page" verbose_name_plural = "Flex Pages"
class NewsPage(Page) : """ News page temaple""" template = "news/news_page.html" # @todo add streamfields content_stream = StreamField( [ ("title_and_text", my_blocks.TitleAndTextBlock()), ("full_richText", my_blocks.RichTextBlock()), ("simple_richText", my_blocks.SimpleRichTextBlock()), ("cards", my_blocks.CardBlock()), ("cta", my_blocks.CtaBlock()), ("button_url",my_blocks.ButtonBlock()), ("char_block", blocks.CharBlock( required=True, help_text='Oh wow this is help text!!', min_length=10, max_length=50, template="streams/char_block.html", )) ], null = True, blank = True ) subtitle = models.CharField(max_length = 100 , null = True , blank = True) content_panels = Page.content_panels + [ FieldPanel("subtitle"), StreamFieldPanel("content_stream") ] class Meta: verbose_name = "News Page" verbose_name_plural = "News Pages"
class FlexPage(Page): template = "flex/flex_page.html" parent_page_types = [ 'flex.Flexpage', 'home.HomePage', ] subpage_types = [ 'flex.FlexPage', 'contact.ContactPage', ] subtitle = models.CharField(max_length=100, null=True, blank=True) content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("full_richtext", blocks.RichTextBlock()), ("cards", blocks.CardBLock()), ("cta", blocks.CTABlock()), ("button_block", blocks.ButtonBlock()), ], null=True, blank=True, ) content_panels = Page.content_panels + [ FieldPanel("subtitle"), StreamFieldPanel("content") ] class Meta: verbose_name = "Flex Page" verbose_name_plural = "flex pages"
class AboutPage(Page): """About page""" max_count = 1 template = "about/about.html" banner_image = models.ForeignKey( "wagtailimages.Image", null=True, blank=True, related_name="+", on_delete=models.SET_NULL, ) banner_title = models.CharField(max_length=120, blank=True, null=True) content = StreamField([("full_richtext", blocks.RichTextBlock())], null=True, blank=True) team_intro_large_text = models.CharField(max_length=50, blank=True, null=True) team_intro_small_text = models.CharField(max_length=50, blank=True, null=True) content_panels = Page.content_panels + [ FieldPanel("banner_title"), ImageChooserPanel("banner_image"), StreamFieldPanel("content"), MultiFieldPanel([ FieldPanel("team_intro_small_text"), FieldPanel("team_intro_large_text"), InlinePanel("team") ], heading="Add team members"), ]
class BlogDetailPage(Page): """Parental blog detail page.""" parent_page_types = ['blog.BlogListingPage'] subpage_types = [] # author = models.ForeignKey(User, on_delete=models.CASCADE, related_name="posts", null=True, blank=True) custom_title = models.CharField( max_length=100, blank=False, null=False, help_text='Overwrites the default title', # verbose_name="タイトル" ) banner_image = models.ForeignKey( "wagtailimages.Image", blank=False, null=True, related_name="+", on_delete=models.SET_NULL, ) image_alt = models.CharField( max_length=100, blank=True, null=True, help_text='Add some alt text', ) categories = ParentalManyToManyField("blog.BlogCategory", blank=True, related_name="posts") tags = ClusterTaggableManager(through=BlogPageTag, blank=True) content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("full_richtext", blocks.RichTextBlock()), ("simple_richtext", blocks.SimpleRichTextBlock()), # ("simple_richtext", blocks.SimpleRichTextBlock(features=["bold", "italic"])), ("cards", blocks.CardBlock()), ("cta", blocks.CTABlock()), ], null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel("custom_title"), ImageChooserPanel("banner_image"), FieldPanel("image_alt", heading="Image Alt (Option)"), MultiFieldPanel([ InlinePanel("blog_authors", label="Author", min_num=1, max_num=4) ], heading="Author(s)"), FieldPanel("categories", widget=forms.CheckboxSelectMultiple), FieldPanel("tags"), StreamFieldPanel("content"), ]
class BlogDetailPage(Page): """ Parental blog Detail page """ subpage_types = [] parent_page_types = ['blog.BlogListingPage'] tags = ClusterTaggableManager(through=BlogPageTag, blank=True) custom_title = models.CharField( max_length=100, blank=False, null=False, help_text='Add your title', ) banner_image = models.ForeignKey( 'wagtailimages.Image', blank=False, null=True, related_name='+', on_delete=models.SET_NULL, ) categories = ParentalManyToManyField('blog.BlogCategory', blank=True) content = StreamField([ ('title_and_text', blocks.TitleAndTextBlock()), ('full_richtext', blocks.RichTextBlock()), ('cards', blocks.CardBlock()), ('cta', blocks.CTABlock()), ], null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel('custom_title'), FieldPanel("tags"), ImageChooserPanel('banner_image'), StreamFieldPanel('content'), MultiFieldPanel([ InlinePanel('blog_authors', label='Author', min_num=1, max_num=4) ], heading='Authors'), MultiFieldPanel( [FieldPanel('categories', widget=forms.CheckboxSelectMultiple)], heading='Categories'), ] api_fields = [ APIField('blog_authors'), APIField('content'), ] def save(self, *args, **kwargs): key = make_template_fragment_key('blog_post_preview', [self.id]) cache.delete(key) return super().save(*args, **kwargs)
class BlogDetailPage(Page): template = "blog/blog_detail.html" subpage_types =[] parent_page_types = ['blog.BlogListingPage'] custom_title = models.CharField( max_length = 100, blank = True, null = True, help_text = 'Overwrites the default title' ) blog_image = models.ForeignKey( "wagtailimages.Image", blank = False, null = True, related_name ='+', on_delete = models.SET_NULL, ) categories = ParentalManyToManyField("blog.BlogCategory") content = StreamField( [ ("title_and_text",blocks.TitleAndTextBlock()), ("full_richtext",blocks.RichTextBlock()), ("cards",blocks.CardBLock()), ("cta",blocks.CTABlock()), ], null =True, blank=True, ) content_panels = Page.content_panels + [ FieldPanel("custom_title"), ImageChooserPanel("blog_image"), MultiFieldPanel( [ InlinePanel("blog_authors",label="Author",min_num=1,max_num=4) ],heading="Author(s)" ), MultiFieldPanel( [ FieldPanel("categories",widget= forms.CheckboxSelectMultiple) ],heading="Categories" ), StreamFieldPanel("content"), ] api_fields =[ APIField("blog_authors"), APIField("content"), ]
class HomePage(RoutablePageMixin, Page): """Home page model.""" templates = "home/home_page.html" max_count = 1 # Create new field banner_title = models.CharField(max_length=100, blank=False, null=True) banner_subtitle = RichTextField(features=["bold", "italic"]) banner_image = models.ForeignKey("wagtailimages.Image", null=True, blank=False, on_delete=models.SET_NULL, related_name="+") banner_cta = models.ForeignKey("wagtailcore.Page", null=True, blank=True, on_delete=models.SET_NULL, related_name="+") content = StreamField([("title_and_text", blocks.TitleAndTextBlock()), ("rich_text", blocks.RichTextBlock()), ("simple_text", blocks.SimpleTextBlock()), ("cards", blocks.CardBlock()), ("cta", blocks.CTABlock()), ("button", blocks.ButtonBlock())], null=True, blank=True) content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel("banner_title"), FieldPanel("banner_subtitle"), ImageChooserPanel("banner_image"), PageChooserPanel("banner_cta"), ], heading="Banner Options"), MultiFieldPanel([ InlinePanel("carousel_images", max_num=5, min_num=1, label="Image") ], heading="Carousel Images"), StreamFieldPanel("content") ] class Meta: verbose_name = "Home Page" verbose_name_plural = "Home Pages" @route(r'^subscribe/$') def the_subscribe_page(self, request, *args, **kwargs): context = self.get_context(request, *args, **kwargs) return render(request, "home/subscribe.html", context)
class MyblogDetailPage(Page): """Blog detail page""" template = "myblog/myblog_detail_page.html" custom_title = models.CharField( max_length=100, blank=False, null=False, help_text="Overwrites default title" ) blog_image = models.ForeignKey( "wagtailimages.Image", blank=False, null=True, on_delete=models.SET_NULL, related_name="+" ) categories = ParentalManyToManyField("myblog.MyBlogCategory", blank=True) content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("rich_text", blocks.RichTextBlock()), ("simple_text", blocks.SimpleTextBlock()), ("cards", blocks.CardBlock()), ("cta", blocks.CTABlock()) ], null=True, blank=True ) content_panels = Page.content_panels + [ FieldPanel("custom_title"), ImageChooserPanel("blog_image"), MultiFieldPanel( [ InlinePanel("blog_authors", label="Author", min_num=1, max_num=5) ], heading="Author(s)" ), MultiFieldPanel( [ FieldPanel("categories", widget=forms.CheckboxSelectMultiple), ], heading="categories" ), StreamFieldPanel("content"), ]
class BlogDetailPage(Page): """Parental Blog Detail Page.""" custom_title = models.CharField( max_length=100, blank=False, null=False, help_text="Overwrites the default title", ) description = RichTextField(features=[], blank=True, null=True) banner_image = models.ForeignKey( "wagtailimages.Image", blank=False, null=True, related_name="+", on_delete="models.SET_NULL", ) content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("full_richtext", blocks.RichTextBlock()), ("simple_richtext", blocks.SimpleRichTextBlock()), ("cards", blocks.CardBlock()), ("cta", blocks.CTABlock()), ], null=True, blank=True, ) categories = ParentalManyToManyField("blog.BlogCategory", blank=True) content_panels = Page.content_panels + [ FieldPanel("custom_title"), ImageChooserPanel("banner_image"), FieldPanel("description"), MultiFieldPanel( [ InlinePanel( "blog_authors", label="Author", min_num=1, max_num=10 ) ], heading="Author(s)", ), MultiFieldPanel( [FieldPanel("categories", widget=forms.CheckboxSelectMultiple)], heading="Categories", ), StreamFieldPanel("content"), ]
class BlogDetailPage(Page): subpage_types = [] tags = ClusterTaggableManager(through=BlogPageTag, blank=True) custom_title = models.CharField( max_length=100, blank=False, null=False, help_text= "Overwrites the default title", ) banner_image = models.ForeignKey( "wagtailimages.Image", blank=False, null=True, related_name = "+", on_delete= models.SET_NULL, ) categories = ParentalManyToManyField("blog.BlogCategory",blank=True,) content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("full_richtext", blocks.RichTextBlock()), ("simple_richtext", blocks.SimpleRichTextBlock()), ("cards", blocks.CardBlock()), ("cta", blocks.CTABlock()), ], null= True, blank = True ) content_panels = Page.content_panels + [ FieldPanel("custom_title"), FieldPanel("tags"), ImageChooserPanel("banner_image"), StreamFieldPanel("content"), MultiFieldPanel( [ InlinePanel("blog_authors", label="Author", min_num=0, max_num=4) ], heading="Author(s)" ), MultiFieldPanel( [ FieldPanel("categories", widget=forms.CheckboxSelectMultiple) ], heading="Categories" ), ]
class FlexPage(Page): content = StreamField( [ ("title", blocks.TitleBlock()), ("text", blocks.TextBlock()), ("richtext", blocks.RichTextBlock()), ], null=True, blank=True, ) content_panels = Page.content_panels + [ StreamFieldPanel("content"), ]
class GenericContentPage(Page): parent_page_types = ["home.HomePage", "lifeevents.LifeEventPage"] image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+' ) summary = models.CharField(max_length=200, blank=False, null=True, help_text="A short summary of the page that appears on the homepage and in search results") intro = models.CharField(max_length=400, blank=False, null=True, help_text="Appears under the title") popular = models.BooleanField(null=True, help_text="Show in the Popular advice section on the homepage") content = StreamField( [ ("rich_text", blocks.RichTextBlock()), ("person_profile", blocks.PersonProfileBlock()), ("call_to_action", blocks.CallToActionButton()), ("financial_help_checker", blocks.FinancialHelpChecker()), ("needs_explorer", blocks.NeedsExplorer()) ], null=True, blank=True ) api_fields = [ APIField("summary"), APIField("intro"), APIField("image"), APIField("content"), APIField("external_links"), APIField("popular") ] content_panels = Page.content_panels + [ FieldPanel("summary"), FieldPanel("intro"), ImageChooserPanel('image'), FieldPanel("popular", widget=CheckboxInput), StreamFieldPanel("content"), InlinePanel("external_links", heading="External links") ]
class FlexPage(Page): template = 'flex/flex_page.html' content = StreamField([("title_and_text", blocks.TitleAndTextBlock()), ("full_richtext", blocks.RichTextBlock()), ("simple_richtext", blocks.SimpleRichTextBlock())], null=True, blank=True) subtitle = models.CharField(max_length=100, null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel("subtitle"), StreamFieldPanel("content") ] class Meta: verbose_name = "Flex Page" verbose_name_plural = "Flex_Pages"
class ContactPage(WagtailCaptchaEmailForm): """Contact Page containing form a Captcha verification""" max_count = 1 banner_image = models.ForeignKey( "wagtailimages.Image", blank=False, null=True, related_name="+", on_delete=models.SET_NULL, ) template = "contact/contact_page.html" intro = RichTextField(blank=True) thank_you_text = RichTextField(blank=True) content = StreamField( [ ("full_richtext", blocks.RichTextBlock()), ], null=True, blank=True, ) contact_small_text = models.CharField(max_length=50, blank=True, null=True) contact_large_text = models.CharField(max_length=50, blank=True, null=True) content_panels = AbstractEmailForm.content_panels + [ FieldPanel('intro'), ImageChooserPanel("banner_image"), FieldPanel("contact_small_text"), FieldPanel("contact_large_text"), InlinePanel('form_fields', label="Form Fields"), FieldPanel('thank_you_text'), MultiFieldPanel([ FieldRowPanel([ FieldPanel('from_address', classname="col6"), FieldPanel('to_address', classname="col6") ]), FieldPanel('subject'), ], heading="Email Settings"), StreamFieldPanel("content"), ]
class HomePage(Page): template = 'home/home_page.html' max_count = 1 home_page_title = models.CharField(max_length=50, blank=True, null=True) home_page_subtitle = RichTextField(features=["bold", "italic"]) top_home_page_image = models.ForeignKey( "wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+", ) home_page_cta = models.ForeignKey( "wagtailcore.Page", null=True, blank=True, on_delete=models.SET_NULL, related_name="+", ) home_page_panels = StreamField([ ('title_and_text', blocks.TitleAndTextBlock()), ('full_richtext', blocks.RichTextBlock()), ('simple_richtext', blocks.SimpleRichTextBlock()), ('service_cards', blocks.CardBlock()), ], null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel('home_page_title'), FieldPanel('home_page_subtitle'), ImageChooserPanel('top_home_page_image'), PageChooserPanel('home_page_cta'), StreamFieldPanel('home_page_panels'), ] class Meta: verbose_name = "Home Page" verbose_name_plural = "Home Pages"
class FlexPage(Page): """Flexible Page Class""" templates = "flex/flex_page.html" parent_page_types = ["home.HomePage"] content = StreamField([ ("title_and_text", blocks.TitleAndTextBlock()), ("full_richtext", blocks.RichTextBlock()), ("simple_richtext", blocks.LimitedRichTextBlock()), ], null=True, blank=True) subtitle = models.CharField(max_length=100, null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel('subtitle'), StreamFieldPanel('content'), ] class Meta: verbose_name = "Flexible Page" verbose_name_plural = "Flexible Pages"
class HomePageCarouselImages(Orderable): """Between one and five images for the homepage carousel""" page = ParentalKey("home.HomePage", related_name="carousel_images") carousel_image = models.ForeignKey( "wagtailimages.Image", null=True, # the page already exists so this is the default value blank=False, # The field cannot be blank on_delete=models. SET_NULL, # When image is deleted, we don't want anything else to be deleted related_name="+", # Not using a related name ) carousel_title = models.CharField(null=True, blank=True, max_length=100) carousel_text = models.CharField(null=True, blank=True, max_length=250) content = StreamField([("cta", blocks.CTABlock())], null=True, blank=True) content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("full_richtext", blocks.RichTextBlock()), ("simple_richtext", blocks.SimpleRichTextBlock()), ("cards", blocks.CardBlock()), ("cta", blocks.CTABlock()), ("button", blocks.ButtonBlock()), ], null=True, blank=True, ) panels = [ ImageChooserPanel("carousel_image"), FieldPanel("carousel_title"), FieldPanel("carousel_text"), StreamFieldPanel("content"), ]
class FlexPage(Page): template = 'flex/flex_page.html' subpage_types = ['flex.FlexPage', 'contact.ContactPage'] parent_page_types = ['flex.FlexPage', 'home.HomePage'] content = StreamField([('title_and_text', blocks.TitleAndTextBlock()), ('full_richtext', blocks.RichTextBlock()), ('cards', blocks.CardBlock()), ('cta', blocks.CTABlock()), ('button', blocks.ButtonBlock())], null=True, blank=True) subtitle = models.CharField(max_length=100, null=True, blank=True) content_panels = Page.content_panels + [ FieldPanel('subtitle'), StreamFieldPanel('content'), ] class Meta: verbose_name = 'Flex Page' verbose_name_plural = 'Flex Pages'
class BlogDetailPage(Page): """Blog detail page""" template = "blog/blog_detail_page.html" custom_title = models.CharField( max_length=120, blank=False, null=False, help_text="Overwrites the default title", ) description = models.CharField( max_length=300, blank=False, null=False, help_text="Description which will appear in the listing", ) banner_image = models.ForeignKey( "wagtailimages.Image", blank=False, null=True, related_name="+", on_delete="models.SET_NULL", ) quick_facts = RichTextField(blank=True, null=True) streams = StreamField( [ ("full_richtext", blocks.RichTextBlock()), ("large_image", blocks.SingleImageBlockLarge()), ("small_image", blocks.SingleImageBlockSmall()), ("youtube_video", blocks.YouTubeEmbedBlock()), ], null=True, blank=True, ) category = ParentalManyToManyField("blog.BlogCategory", blank=True) def get_context(self, request): """get categories & Blog posts""" context = super().get_context(request) categories = BlogCategory.objects.all() context["categories"] = categories # Get related posts based on current category current_cat = [] for category in self.category.all(): current_cat.append(category) related = (BlogDetailPage.objects.public().live().filter( category__name__in=current_cat).order_by( "-first_published_at").not_page(self)[:2]) context["related"] = related return context content_panels = Page.content_panels + [ MultiFieldPanel( [ FieldPanel("custom_title"), FieldPanel("description"), ImageChooserPanel("banner_image"), ], heading="Blog page information", ), MultiFieldPanel([ InlinePanel("blog_authors", label="Author", min_num=1, max_num=10), ], heading="Author(s)"), FieldPanel("category", widget=forms.CheckboxSelectMultiple), FieldPanel("quick_facts"), StreamFieldPanel("streams"), ] @property def display_title(self): return title_method(self)
class HomePage(Page): """Home Page Model""" templates = "templates/home/home_page.html" # if not specified template loads from templates/app_name/page_class # Banner Content Fields banner_title = models.CharField(max_length=100, blank=False, null=True) banner_subtitle = RichTextField(features=["bold", "italic"]) banner_image = models.ForeignKey( "wagtailimages.Image", null=True, # might cause migration problem, if previously not specified blank=False, on_delete=models.SET_NULL, related_name="+" # use same as field name ) # Call to action, create another wagtail page banner_cta = models.ForeignKey( "wagtailcore.Page", null=True, blank=True, on_delete=models.SET_NULL, related_name="+" ) content = StreamField( [ ("title_and_text", blocks.TitleAndTextBlock()), ("full_rich_text", blocks.RichTextBlock()), ("simple_richtext", blocks.SimpleRichTextBlock()), ("cards", blocks.CardBlock()), ("call_to_action", blocks.CTABlock()), ], null=True, blank=True ) # Created fields must be registered here content_panels = Page.content_panels + [ # Banner MultiFieldPanel([ FieldPanel("banner_title"), FieldPanel("banner_subtitle"), ImageChooserPanel("banner_image"), PageChooserPanel("banner_cta"), ], heading="Banner Options"), # content StreamFieldPanel("content"), # Image Carousel MultiFieldPanel([ # Why not stream field? # Because stream fields can be unlimited, we want to limit the no of fields InlinePanel("carousel_images", max_num=5, min_num=1, label="Image") ], heading="Carousel Images") ] # only one home page per site max_count = 1 class Meta: verbose_name = "Home Page" verbose_name_plural = "Home Pages"
class BlogDetailPage(BannerPage): template = "blog/post.html" subpage_types = [] parent_page_type = [ "blog.BlogListingPage", ] author = models.ForeignKey( BlogAuthor, blank=False, null=True, on_delete=models.SET_NULL, ) notify_newsletter_subscribers = models.BooleanField( default=False, verbose_name="Newsletter", ) notify_telegram_subscribers = models.BooleanField( default=False, verbose_name="Telegram", ) content = StreamField( [ ("richtext", blocks.RichTextBlock()), ("image", blocks.FigureBlock()), ("code", blocks.CodeFragmentBlock()), ("HTML", RawHTMLBlock(icon="fa-html5")), ("Terminal", TerminalBlock()), ("latex", blocks.MathBlock()), ("blockquote", blocks.BlockQuoteBlock()), ("youtube", blocks.YouTubeBlock()), ], blank=True, ) content_panels = BannerPage.content_panels + [ SnippetChooserPanel("author"), StreamFieldPanel("content"), ] edit_handler = TabbedInterface([ ObjectList(content_panels, heading="Content"), ObjectList(BannerPage.promote_panels, heading="Promote"), ObjectList( BannerPage.settings_panels + [ MultiFieldPanel( [ FieldPanel("notify_newsletter_subscribers"), FieldPanel("notify_telegram_subscribers"), ], heading="Notification Channels", help_text= "Choose which channels to notifiy about this blog post.", ) ], heading="Settings", ), ])