Esempio n. 1
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    max_count = 1

    standard = StreamField([
        ("title_and_text", blocks.TitleAndTextBlock()),
        ("richtext", blocks.RichtextBlock()),
        ("simplerichtext", blocks.SimpleRichtextBlock()),
        ("buttons", blocks.ButtonBlock()),
    ],
                           null=True,
                           blank=True)

    sections = StreamField([
        ("cards", blocks.CardBlock()),
        ("products", blocks.ProductCardBlock()),
        ("cta", blocks.CTABlock()),
    ],
                           null=True,
                           blank=True)

    content_panels = Page.content_panels + [
        StreamFieldPanel("standard"),
        StreamFieldPanel("sections"),
    ]

    api_fields = [
        APIField("standard"),
        APIField("sections"),
    ]
Esempio n. 2
0
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 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"
Esempio n. 4
0
class FlexPage(Page):
    """Flexible page class"""

    template = 'flex/flex_page.html'

    content = StreamField([
        ("title_and_text", blocks.TitleAndTextBlock()),
        ("RichText_Tool", blocks.RichtextBlock()),
        ("Simple_RichText_Tool", blocks.SimpleRichtextBlock()),
        ("Cards", blocks.CardBlock()),
        ("Call_to_action", blocks.CTABlock()),
        ("Button_Url", blocks.ButtonBlock()),
    ],
                          null=True,
                          blank=True)

    subtitle = models.CharField(max_length=100, blank=True, null=True)

    content_panels = Page.content_panels + [
        FieldPanel('subtitle'),
        StreamFieldPanel('content'),
    ]

    class Meta:  # noqa

        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Esempio n. 5
0
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"
Esempio n. 6
0
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"
Esempio n. 7
0
class FlexPage(Page):
    """Flexibile page class."""

    template = "flex/flex_page.html"
    subpage_types = ['flex.FlexPage', 'contact.ContactPage']
    flex_image = models.ForeignKey(
        "wagtailimages.Image",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )
    parent_page_types = [
        'flex.FlexPage',
        'home.HomePage',
    ]
    content = StreamField(
        [
            ("title", blocks.HeaderTitleBlock()),
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("image", blocks.ImageBlock()),
            ("full_richtext", blocks.RichtextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
            ("cards", blocks.CardBlock()),
            ("cta", blocks.CTABlock()),
            ("button", blocks.ButtonBlock()),
            ("simple_card", blocks.SimpleCardBlock()),
            ("carousel", blocks.CarouselBlock()),
            ("char_block",
             streamfield_blocks.CharBlock(
                 required=True,
                 help_text='Oh wow this is help text!!',
                 min_length=10,
                 max_length=50,
                 template="streams/char_block.html",
             )),
            ("simple_column", ColumnBlock()),
            ('two_columns', TwoColumnBlock()),
        ],
        null=True,
        blank=True,
    )

    subtitle = models.CharField(max_length=100, null=True, blank=True)

    content_panels = Page.content_panels + [
        FieldPanel("subtitle"),
        ImageChooserPanel("flex_image"),
        StreamFieldPanel("content"),
    ]

    class Meta:  # noqa
        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Esempio n. 8
0
class BasicPage(Page):
    template = "basic/basic_page.html"
    subpage_types = ['basic.BasicPage']
    parent_page_types = ['basic.BasicPage', 'wagtailcore.Page']

    banner_title = models.CharField(max_length=150, null=True, blank=True)
    banner_subtitle = models.CharField(max_length=300, blank=True, null=True)
    banner_image = models.ForeignKey(
        get_image_model_string(),
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )

    body = StreamField([
        ("cta", blocks.CallToActionBlock()),
        ("large_text", blocks.LargeTextBlock()),
        ("large_listing_block", blocks.LargeListingBlock()),
        ("small_listing_block", blocks.SmallListingBlock()),
        ("richtext",
         wagtail_blocks.RichTextBlock(
             template="streams/simple_richtext_block.html",
             features=["h3", "bold", "italic", "ol", "ul", "link", "image"],
             group="Text Sections")),
        ("buttons", blocks.ButtonBlock()),
        ("image_gallery", blocks.ImageGallery()),
        ("hr", blocks.HorizontalRuleBlock()),
        ("horizontal_gallery", blocks.HorizontalGallery()),
    ],
                       null=True,
                       blank=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('banner_title'),
            FieldPanel('banner_subtitle'),
            ImageChooserPanel('banner_image')
        ],
                        heading='Banner Settings'),
        StreamFieldPanel("body"),
        MultiFieldPanel([SnippetChooserPanel("footer_cta")],
                        'Optional footer cta'),
    ]

    # Optional Footer CTA
    footer_cta = models.ForeignKey(
        'cta.CallToAction',
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
        related_name='+',
        help_text='Optional footer call to action for this page')
Esempio n. 9
0
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)
Esempio n. 10
0
class FlexPage(Page):
    """Flexible page class."""

    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()),
         ("simple_richtext", blocks.SimpleRichtextBlock()),
         ("cards", blocks.CardBlock()), ("img_text", blocks.ImgText()),
         ("image", blocks.ImageBlock()), ("text_img", blocks.TextImg()),
         ("cta", blocks.CTABlock()), ("button", blocks.ButtonBlock()),
         ("char_block",
          streamfield_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"),
    ]

    class Meta:  # noqa
        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Esempio n. 11
0
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()),
        ("testimonials", blocks.TestimonialBlock()),
        ("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"),
    ]
Esempio n. 12
0
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"),
    ]
Esempio n. 13
0
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'
Esempio n. 14
0
class BasicPage(Page):
    template = "basic/basic_page.html"
    subpage_types = ['basic.BasicPage']
    parent_page_types = ['basic.BasicPage', 'wagtailcore.Page']

    banner_title = models.CharField(max_length=150, null=True, blank=True)
    banner_subtitle = models.CharField(max_length=300, blank=True, null=True)
    banner_image = models.ForeignKey(
        get_image_model_string(),
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )
    footer_cta = models.ForeignKey(
        'cta.CallToAction',
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
        related_name='+',
        help_text='Optional footer call to action for this page')

    social_sharing_image = models.ForeignKey(
        'wagtailimages.Image',
        on_delete=models.SET_NULL,
        blank=True,
        null=True,
        related_name='+',
    )

    body = StreamField([
        ("cta", blocks.CallToActionBlock()),
        ("large_text", blocks.LargeTextBlock()),
        ("large_listing_block", blocks.LargeListingBlock()),
        ("small_listing_block", blocks.SmallListingBlock()),
        ("richtext",
         wagtail_blocks.RichTextBlock(
             template="streams/simple_richtext_block.html",
             features=["h3", "bold", "italic", "ol", "ul", "link", "image"],
             group="Text Sections")),
        ("buttons", blocks.ButtonBlock()),
        ("image_gallery", blocks.ImageGallery()),
        ("hr", blocks.HorizontalRuleBlock()),
        ("horizontal_gallery", blocks.HorizontalGallery()),
        ("child_pages", blocks.HorizontalGallery()),
    ],
                       null=True,
                       blank=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('banner_title'),
            FieldPanel('banner_subtitle'),
            ImageChooserPanel('banner_image')
        ],
                        heading='Banner Settings'),
        StreamFieldPanel("body"),
        MultiFieldPanel([SnippetChooserPanel("footer_cta")],
                        'Optional footer cta'),
    ]

    promote_panels = Page.promote_panels + [
        ImageChooserPanel("social_sharing_image"),
    ]

    def get_template(self, request, *args, **kwargs):
        if request.is_preview:
            self.template = "basic/basic_page_preview.html"
        return self.template

    def save(self, *args, **kwargs):
        key = make_template_fragment_key(
            "page_cache",
            [self.id],
        )
        cache.delete(key)

        return super().save(*args, **kwargs)
Esempio n. 15
0
class HomePage(RoutablePageMixin, Page):
    """Home page model."""

    template = "home/home_page.html"
    max_count = 1
    subpage_types = [
        'blog.BlogListingPage',
        'contact.ContactPage',
        'flex.FlexPage',
    ]
    parent_page_type = [
        'wagtailcore.Page'
    ]
    
    banner_title = models.CharField(max_length=100, blank=False, null=True)
    banner_cta = models.ForeignKey(
        "wagtailcore.Page",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+",
   )

    content = StreamField([
            ("title", blocks.HeaderTitleBlock()),
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("full_richtext", blocks.RichtextBlock()),            
            ("image", blocks.ImageBlock()),            
            ("cards", blocks.CardBlock()),
            ("cta", blocks.CTABlock()),
            ("button", blocks.ButtonBlock()),
            ("simple_card", blocks.SimpleCardBlock()),
            ("simple_column", ColumnBlock()),
            ('two_columns', TwoColumnBlock()),
    ], null=True, blank=True)

    api_fields = [
        APIField("banner_title"),
        APIField("banner_cta"),
        APIField("carousel_images"),
        APIField("content"),
    ]

    content_panels = Page.content_panels + [
        MultiFieldPanel(
            [InlinePanel("carousel_images", max_num=5, min_num=1, label="Image")],
            heading="Carousel Images",
        ),
        StreamFieldPanel("content"),
    ]

    # This is how you'd normally hide promote and settings tabs
    # promote_panels = []
    # settings_panels = []

    banner_panels = [
        MultiFieldPanel(
            [
                FieldPanel("banner_title"),
                PageChooserPanel("banner_cta"),
            ],
            heading="Banner Options",
        ),
    ]

    edit_handler = TabbedInterface(
        [
            ObjectList(content_panels, heading='Content'),
            ObjectList(banner_panels, heading="Banner Settings"),
            ObjectList(Page.promote_panels, heading='Promotional Stuff'),
            ObjectList(Page.settings_panels, heading='Settings Stuff'),
        ]
    )



    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)

    def get_admin_display_title(self):
        return "Custom Home Page Title"

# # This will change the "title" field 's verbose name to "Custom Name".
# # But you'd still reference it in the template as `page.title`
# HomePage._meta.get_field("title").verbose_name = "Custom Name"
# # Here we are removing the help text. But to change it, simply change None to a string.
# HomePage._meta.get_field("title").help_text = None
# # Below is the new default title for a Home Page.
# # This only appears when you create a new page.
# HomePage._meta.get_field("title").default = "Default HomePage Title"
# # Lastly, we're adding a default `slug` value to the page.
# # This does not need to reflect the same (or similar) value that the `title` field has.
# HomePage._meta.get_field("slug").default = "default-homepage-title"
Esempio n. 16
0
class HomePage(RoutablePageMixin, Page):
    """Home page model."""

    template = "home/home_page.html"
    subpage_types = [
        'blog.BlogListingPage',
        'contact.ContactPage',
        'flex.FlexPage',
    ]
    parent_page_type = ['wagtailcore.Page']

    banner_title = models.CharField(max_length=100, blank=False, null=True)
    banner_subtitle = RichTextField(features=["bold", "italic"],
                                    blank=True,
                                    null=True)
    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()),
                           ("full_richtext", blocks.RichtextBlock()),
                           ("simple_richtext", blocks.SimpleRichtextBlock()),
                           ("cards", blocks.CardBlock()),
                           ("img_text", blocks.ImgText()),
                           ("image", blocks.ImageBlock()),
                           ("text_img", blocks.TextImg()),
                           ("cta", blocks.CTABlock()),
                           ("button", blocks.ButtonBlock()),
                           ("char_block",
                            streamfield_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)

    api_fields = [
        APIField("banner_title"),
        APIField("banner_subtitle"),
        APIField("banner_image"),
        APIField("banner_cta", serializer=BannerCTASerializer()),
        APIField("carousel_images"),
        APIField("content"),
        APIField("a_custom_api_response"),
    ]

    @property
    def a_custom_api_response(self):
        # return ["SOMETHING CUSTOM", 3.14, [1, 2, 3, 'a', 'b', 'c']]
        # logic goes in here
        return f"Banner Title Is: {self.banner_title}"

    content_panels = Page.content_panels + [
        MultiFieldPanel(
            [
                InlinePanel(
                    "carousel_images", max_num=5, min_num=1, label="Image")
            ],
            heading="Carousel Images",
        ),
        StreamFieldPanel("content"),
    ]

    # This is how you'd normally hide promote and settings tabs
    # promote_panels = []
    # settings_panels = []

    banner_panels = [
        MultiFieldPanel(
            [
                FieldPanel("banner_title"),
                FieldPanel("banner_subtitle"),
                ImageChooserPanel("banner_image"),
                PageChooserPanel("banner_cta"),
            ],
            heading="Banner Options",
        ),
    ]

    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='Content'),
        ObjectList(banner_panels, heading="Banner Settings"),
        ObjectList(Page.promote_panels, heading='Promotional Stuff'),
        ObjectList(Page.settings_panels, heading='Settings Stuff'),
    ])

    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)

    def get_admin_display_title(self):
        return "Custom Home Page Title"