Exemple #1
0
class StandardPage(Page):
    """Standard page model"""

    template = "standard/standard_page.html"

    search_fields = Page.search_fields + [
        index.SearchField('search_description')
    ]

    body = StreamField(
        [
            ("richtext", blocks.RichtextBlock(group="Format and Text")),
            ("two_column_block", blocks.ColumnsBlock(group="Format and Text")),
            ("info_box_block", blocks.InfoBoxBlock(group="Format and Text")),
            ("footnote_block", blocks.FootnoteBlock(group="Format and Text")),
            ("image_block", blocks.ImageBlock(group="Layout and Images")),
            ("fellows_block", blocks.FellowsBlock(group="Layout and Images")),
            ("clear_block", blocks.ClearBlock(group="Layout and Images")),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        StreamFieldPanel("body"),
        MultiFieldPanel(
            [InlinePanel("sidebar", max_num=3, label="Sidebar Section")],
            heading="Sidebar",
        ),
    ]

    class Meta:

        verbose_name = "Standard Page"
        verbose_name_plural = "Standard Pages"
Exemple #2
0
class MembCollectionIndexPage(Page):
    """Landing page for member collection search box"""

    template = "memb_collections/memb_collections_index_page.html"
    max_count = 1
    subpage_types = []
    parent_page_types = ['home.HomePage']

    search_fields = Page.search_fields + [
        index.SearchField('search_description')
    ]

    body = StreamField(
        [
            ("richtext", blocks.RichtextBlock()),
            ("image_block", blocks.ImageBlock()),
            ("new_row", blocks.NewRow()),
            ("memb_coll_search_block", blocks.MembCollSearchBlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        StreamFieldPanel("body"),
        MultiFieldPanel(
            [InlinePanel("sidebar", max_num=3, label="Sidebar Section")],
            heading="Sidebar",
        ),
    ]

    class Meta:

        verbose_name = "Member Collection Index Page"
        verbose_name_plural = "Member Collection Index Pages"
Exemple #3
0
class NewsletterSignupPage(Page):
    """Page for embedded Newsletter form code"""

    max_count = 1
    subpage_types = []
    parent_page_types = ['news.NewsIndexPage']

    search_fields = Page.search_fields + [
        index.SearchField('search_description')
    ]

    body = StreamField(
        [
            ("richtext", blocks.RichtextBlock()),
            ("webfeed", blocks.WebFeedBlock()),
            ("image_block", blocks.ImageBlock()),
        ],
        null=True,
        blank=True,
    )

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

    class Meta:

        verbose_name = "Newsletter Form"
        verbose_name_plural = "Newsletter Forms"
class HomePage(Page):

    templates = "home/hompage_page.html"

    carousel_images = StreamField(blocks.CarouselBlock(max_num=3,
                                                       required=False),
                                  blank=True,
                                  null=True)

    content = StreamField(
        [
            ('team', blocks.TeamCards()),
            ('image', blocks.ImageBlock()),
            ("jumbotron", blocks.ActionAreaBlock()),
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
            ("cards", blocks.CardBlock()),
            ("cta", blocks.CTABlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        StreamFieldPanel("carousel_images"),
        StreamFieldPanel("content"),
    ]

    class Meta:
        verbose_name = "Home Page"
        verbose_name_plural = "Home Pages"
Exemple #5
0
class HomePage(Page):
    parent_page_types = ["wagtailcore.Page"]
    sub_heading = models.CharField(
        max_length=140, 
        blank=True, 
        help_text='Subheading text above the banner title',
    )

    banner_background_image = models.ForeignKey(
        'wagtailimages.Image',
        blank=False,
        null=True,
        related_name='+',
        help_text='The banner background image',
        on_delete=models.SET_NULL,
    )

    body = StreamField([
        ("title", blocks.TitleBlock()),
        ("text", blocks.TextBlock()),
        ("image", blocks.ImageBlock()),
    ], null=True, blank=True)

    # Admin page blocks
    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel("sub_heading"),
            ImageChooserPanel("banner_background_image"),
        ], heading="homepage banner"),
        StreamFieldPanel("body"),
    ]
Exemple #6
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"
Exemple #7
0
class NewsStoryPage(Page):
    """News story page model"""

    subpage_types = []
    parent_page_types = ['news.NewsIndexPage']

    search_fields = Page.search_fields + [index.SearchField('excerpt')]

    lead_image = models.ForeignKey(
        "wagtailimages.Image",
        blank=True,
        null=True,
        related_name="+",
        on_delete=models.SET_NULL,
    )
    excerpt = models.TextField(max_length=300, blank=True, null=True)
    body = StreamField(
        [
            ("richtext", blocks.RichtextBlock(group="Format and Text")),
            ("two_column_block", blocks.ColumnsBlock(group="Format and Text")),
            ("info_box_block", blocks.InfoBoxBlock(group="Format and Text")),
            ("footnote_block", blocks.FootnoteBlock(group="Format and Text")),
            ("image_block", blocks.ImageBlock(group="Layout and Images")),
            ("fellows_block", blocks.FellowsBlock(group="Layout and Images")),
            ("clear_block", blocks.ClearBlock(group="Layout and Images")),
        ],
        null=True,
        blank=True,
    )
    story_date = models.DateField(
        default=timezone.now,
        help_text=
        'Defaults to date page was created. If you plan to publish in the future post, change to publish date here.'
    )

    content_panels = Page.content_panels + [
        ImageChooserPanel("lead_image"),
        FieldPanel("excerpt"),
        StreamFieldPanel("body"),
        FieldPanel('story_date'),
    ]

    class Meta:

        verbose_name = "News Story"
        verbose_name_plural = "News Stories"
Exemple #8
0
class ProjectsPage(Page):
    parent_page_types = ["projects.ProjectsListingPage"]
    summary = models.TextField(
        blank=False,
        max_length=500,
        help_text='Give a brief summary of the project. Additional details may be included in this page further down if necessary.'
    )

    languages_used = models.TextField(
        blank=False,
        max_length=100,
        help_text='List all the languages used seperating by comma and connecting the last language with an "and"'
    )

    project_image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=False,
        on_delete=models.SET_NULL,
        help_text='Insert an image to be used for the project. It will be cropped to 570px by 370px',
        related_name="+",
    )

    date_started = models.DateField()

    date_widget = widgets.AdminDateInput(
        attrs = {
            'placeholder': 'dd-mm-yyyy'
        }
    )

    body = StreamField([
        ("title", blocks.TitleBlock()),
        ("text", blocks.TextBlock()),
        ("image", blocks.ImageBlock()),
    ], null=True, blank=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel("summary"),
            FieldPanel("languages_used"),
            ImageChooserPanel("project_image"),
            FieldPanel("date_started", widget=date_widget),
        ], heading="standard details"),
        StreamFieldPanel("body"),
    ]
Exemple #9
0
class FlexPage(Page):
    class Meta:
        verbose_name = "Page"
        verbose_name_plural = "Pages"

    parent_page_types = ["home.HomePage", "flex.FlexPage"]

    body = StreamField([
        ("title", blocks.TitleBlock()),
        ("text", blocks.TextBlock()),
        ("image", blocks.ImageBlock()),
    ],
                       null=True,
                       blank=True)

    content_panels = Page.content_panels + [
        StreamFieldPanel("body"),
    ]
Exemple #10
0
class FlexPage(Page):
    """Flexible Page Class"""

    template = "flex/flexpage.html"

    banner_overlay = ColorField(blank=True,
                                verbose_name='Banner Overlay Color',
                                help_text='Select color of banner overlay',
                                null=True)
    banner_image = models.ForeignKey(
        "wagtailimages.Image",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )

    content = StreamField(
        [
            ('team', blocks.TeamCards()),
            ('image', blocks.ImageBlock()),
            ("jumbotron", blocks.ActionAreaBlock()),
            ("title_and_text", blocks.TitleAndTextBlock()),
            ("simple_richtext", blocks.SimpleRichtextBlock()),
            ("cards", blocks.CardBlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        MultiFieldPanel(
            [
                NativeColorPanel("banner_overlay"),
                ImageChooserPanel("banner_image"),
            ],
            heading="Banner Options",
        ),
        StreamFieldPanel("content"),
    ]

    class Meta:
        verbose_name = "Flex Page"
        verbose_name_plural = "Flex Pages"
Exemple #11
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"
Exemple #12
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"
Exemple #13
0
class BlogPage(Page):
    post_title = models.CharField(
        blank=False,
        max_length=80,
    )

    published_date = models.DateTimeField(default=timezone.now)

    author = models.CharField(max_length=100)

    tags = ClusterTaggableManager(through=TaggedBlog, blank=True)

    summary = models.TextField(
        blank=False,
        max_length=300,
        help_text="A brief summary of the article for the post listing.")

    preview_image = models.ForeignKey(
        'wagtailimages.Image',
        blank=False,
        null=True,
        related_name='+',
        on_delete=models.SET_NULL,
        help_text="The preview image displayed on the post listing.")

    internal_page_link = models.ForeignKey(
        'wagtailcore.Page',
        blank=True,
        null=True,
        related_name='+',
        help_text="Select and internal page to link too.",
        on_delete=models.SET_NULL,
    )

    main_content = StreamField(
        [
            ("blockquote", blocks.BlockquoteBlock()),
            ("Richtext",
             wagtail_blocks.RichTextBlock(
                 template="streams/simple_richtext_block.html",
                 features=["bold", "italic", "h2", "h3", "ol", "ul", "link"])),
            ("ImageAndText", blocks.ImageAndTextBlock()),
            ("Image", blocks.ImageBlock()),
            ("Centered_Image", blocks.ImageCenteredBlock()),
        ],
        null=True,
        blank=True,
    )

    content_panels = Page.content_panels + [
        FieldPanel("post_title"),
        FieldPanel("published_date"),
        FieldPanel("author"),
        ImageChooserPanel("preview_image"),
        FieldPanel("summary"),
        StreamFieldPanel("main_content"),
    ]

    promote_panels = Page.promote_panels + [
        FieldPanel("tags"),
    ]

    def get_read_time(self):
        ''' Returns the read time of the HTML body '''
        string = str(self.main_content)
        result = readtime.of_html(string)
        return result

    def get_context(self, request, *args, **kwargs):
        ''' Returns all Articles or filters the articles by tags using query parameters and returns the filtered list. '''
        context = super().get_context(request, *args, **kwargs)
        post_tag_ids = self.tags.values_list('id', flat=True)
        similar_posts = BlogPage.objects.live().public().filter(
            tags__in=post_tag_ids).exclude(id=self.id)
        similar_posts = similar_posts.annotate(
            same_tags=Count('tags')).order_by('-same_tags',
                                              '-published_date')[:3]
        context["similar_posts"] = similar_posts
        return context
Exemple #14
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"