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): """ Flex page model """ template = "flex/flex.html" # Django models subtitle = models.CharField(max_length=100, null=True, blank=True) # Wagtail models content = StreamField([ ("title_and_text", blocks.TitleAndTextBlock()), ("full_rich_text", blocks.FullRichTextBlock()), ("simple_rich_text", blocks.SimpleRichTextBlock()), ("cards_blocks", blocks.CardBlock()), ], blank=True, null=True) # Add the all of fields to Wagtail panels content_panels = Page.content_panels + [ FieldPanel("subtitle"), StreamFieldPanel("content"), ] class Meta: verbose_name = "Flex page" verbose_name_plural = "Flex pages"
class FlexPage(Page): """Flexible 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): # @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 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): """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 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): 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='Overwrite 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'), 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'), ] 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): """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 BlogDetailPage(Page): """Parental blog detail page. """ 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"), ImageChooserPanel("banner_image"), MultiFieldPanel([ InlinePanel("blog_authors", label="Author", min_num=1, max_num=4) ], heading="Author(s)"), MultiFieldPanel( [FieldPanel("categories", widget=forms.CheckboxSelectMultiple)], heading="Category"), StreamFieldPanel("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 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 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 BlogPostPage(Page): template = "blog/post.html" subpage_types = [] parent_page_types = ['blog.BlogListPage', 'home.HomePage'] intro = models.CharField(max_length=255, blank=False, null=True) cover_image = models.ForeignKey( "wagtailimages.Image", blank=False, null=True, related_name='+', on_delete=models.SET_NULL, ) categories = ParentalManyToManyField("blog.BlogCategory", blank=True) content = StreamField( [ ('inline_image', blocks.InlineImageBlock()), ('paragraph', blocks.SimpleRichTextBlock()), ], null=True, blank=False, ) content_panels = Page.content_panels + [ FieldPanel('intro'), ImageChooserPanel("cover_image"), MultiFieldPanel( [ FieldPanel("categories", widget=forms.CheckboxSelectMultiple), ], heading="Categories", ), StreamFieldPanel("content") ]
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 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"