Ejemplo n.º 1
0
class VolunteerPage(VolunteerRootMixin, Page):
    template = "web/volunteers/volunteer-details.html"
    parent_page_types = ["web.VolunteerListPage"]
    subpage_types = []

    body = StreamField([
        ("heading", blocks.CharBlock(form_classname="full title")),
        ("paragraph", blocks.RichTextBlock(features=RICH_TEXT_FEATURES)),
        ("image", ImageChooserBlock()),
        ("quote", blocks.BlockQuoteBlock()),
        ("attributed_quote", AttributedQuoteBlock()),
    ])
    position = models.CharField(max_length=255,
                                help_text="The name of their role")
    main_image = models.ForeignKey(
        "wagtailimages.Image",
        related_name="+",
        on_delete=models.PROTECT,
        blank=True,
        null=True,
    )

    promote_panels = [FieldPanel("slug")]
    settings_panels = [PrivacyModalPanel()]
    content_panels = Page.content_panels + [
        FieldPanel("position"),
        ImageChooserPanel("main_image"),
        StreamFieldPanel("body"),
    ]

    def save(self, *args, **kwargs):
        self.search_description = f"{self.title}, {self.position} at Anika Legal"
        return super().save(*args, **kwargs)
Ejemplo n.º 2
0
class BlogPage(BlogRootMixin, Page):
    template = "web/blog/blog-details.html"
    parent_page_types = ["web.BlogListPage"]
    subpage_types = []

    body = StreamField([
        ("heading", blocks.CharBlock(form_classname="full title")),
        ("paragraph", blocks.RichTextBlock(features=RICH_TEXT_FEATURES)),
        ("image", ImageChooserBlock()),
        ("quote", blocks.BlockQuoteBlock()),
    ])
    main_image = models.ForeignKey(
        "wagtailimages.Image",
        related_name="+",
        on_delete=models.PROTECT,
        blank=True,
        null=True,
    )

    promote_panels = [FieldPanel("slug")]
    settings_panels = [PrivacyModalPanel()]
    content_panels = Page.content_panels + [
        FieldPanel("owner", heading="Author"),
        MultiFieldPanel(
            [
                ImageChooserPanel("main_image"),
                FieldPanel("search_description"),
            ],
            "Search and social media",
        ),
        StreamFieldPanel("body"),
    ]
class BlogPage(FoundationMetadataPageMixin, Page):

    body = StreamField(base_fields)

    category = ParentalManyToManyField(
        BlogPageCategory,
        help_text='Which blog categories is this blog page associated with?',
        blank=True,
        verbose_name="Categories",
    )

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

    zen_nav = True

    feature_comments = models.BooleanField(
        default=False,
        help_text='Check this box to add a comment section for this blog post.',
    )

    content_panels = Page.content_panels + [
        MultiFieldPanel(
            [
                InlinePanel("authors", label="Author", min_num=1)
            ],
            heading="Author(s)"
        ),
        FieldPanel('category'),
        StreamFieldPanel('body'),
        FieldPanel('feature_comments'),
    ]

    promote_panels = FoundationMetadataPageMixin.promote_panels + [
        FieldPanel('tags'),
    ]

    settings_panels = [
        PublishingPanel(),
        FieldPanel('first_published_at'),
        PrivacyModalPanel(),
    ]

    def get_context(self, request):
        context = super().get_context(request)
        context['related_posts'] = get_content_related_by_tag(self)
        context['coral_talk_server_url'] = settings.CORAL_TALK_SERVER_URL
        context['coral_talk'] = context['coral_talk_server_url'] and self.feature_comments

        # Pull this object specifically using the English page title
        blog_page = BlogIndexPage.objects.get(title_en__iexact='Blog')

        # If that doesn't yield the blog page, pull using the universal title
        if blog_page is None:
            blog_page = BlogIndexPage.objects.get(title__iexact='Blog')

        if blog_page:
            context['blog_index'] = blog_page

        return set_main_site_nav_information(self, context, 'Homepage')
Ejemplo n.º 4
0
class NewsPage(NewsRootMixin, Page):
    template = "web/news/news-details.html"
    parent_page_types = ["web.NewsListPage"]
    subpage_types = []
    body = StreamField([
        ("heading", blocks.CharBlock(form_classname="full title")),
        ("paragraph", blocks.RichTextBlock(features=RICH_TEXT_FEATURES)),
        ("image", ImageChooserBlock()),
        ("quote", blocks.BlockQuoteBlock()),
    ])
    promote_panels = [FieldPanel("slug")]
    settings_panels = [PrivacyModalPanel()]
    content_panels = Page.content_panels + [
        FieldPanel("owner", heading="Author"),
        FieldPanel("search_description", heading="Social description"),
        StreamFieldPanel("body"),
    ]
Ejemplo n.º 5
0
class JobPage(JobsRootMixin, Page):
    template = "web/jobs/job-details.html"
    parent_page_types = ["web.JobListPage"]
    subpage_types = []
    icon = models.CharField(max_length=64, choices=ICON_CHOICES)
    closing_date = models.DateField()
    body = StreamField([
        ("heading", blocks.CharBlock(form_classname="full title")),
        ("paragraph", blocks.RichTextBlock(features=RICH_TEXT_FEATURES)),
        ("image", ImageChooserBlock()),
    ])
    promote_panels = [FieldPanel("slug")]
    settings_panels = [PrivacyModalPanel()]
    content_panels = Page.content_panels + [
        FieldPanel("icon", heading="Icon"),
        FieldPanel("closing_date", heading="Application closing date"),
        FieldPanel("search_description", heading="Short description"),
        StreamFieldPanel("body", heading="Long description"),
    ]
from wagtail.admin.edit_handlers import PublishingPanel, PrivacyModalPanel
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.images.widgets import AdminImageChooser


class CustomImageChooserPanel(ImageChooserPanel):
    def widget_overrides(self):
        return {self.field_name: AdminImageChooser(show_edit_link=False)}


CUSTOM_SETTINGS_PANELS = [
    PublishingPanel(
        help_text=
        'Sekä julkaisu- että poistopäivämäärä ovat vapaaehtoisia kenttiä ja '
        'ne voidaan jättää tyhjäksi. Voit myös halutessasi täyttää vain toisen kentistä.'
    ),
    PrivacyModalPanel(
        help_text='Tällä voit määritellä sivun ja sen alasivujen näkyvyyden.'),
]