How to use the wagtail.wagtailcore.models.Page function in wagtail

To help you get started, we’ve selected a few wagtail examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github torchbox / wagtailapi / tests / models.py View on Github external
# PAGE MODELS
# =============================

# Home page

class HomePage(Page):
    body = RichTextField(blank=True)

    api_fields = (
        'body',
        'carousel_items',
        'related_links',
    )

    search_fields = Page.search_fields + (
        index.SearchField('body'),
    )

    class Meta:
        verbose_name = "Homepage"


class HomePageCarouselItem(Orderable, AbstractCarouselItem):
    page = ParentalKey('HomePage', related_name='carousel_items')

class HomePageRelatedLink(Orderable, AbstractRelatedLink):
    page = ParentalKey('HomePage', related_name='related_links')

HomePage.content_panels = Page.content_panels + [
    FieldPanel('body', classname="full"),
github rapidpro / rapidpro-community-portal / portal_pages / models.py View on Github external
FieldPanel('service'),
    ]


class ExpertiseMarketplaceEntry(Orderable, models.Model):
    expertise = models.ForeignKey(Expertise, related_name="+")
    page = ParentalKey(MarketplaceEntryPage, related_name='expertise_tags')
    panels = [
        FieldPanel('expertise'),
    ]


# CaseStudy index page


class CaseStudyIndexPage(RoutablePageMixin, Page, TopImage):
    intro = RichTextField(blank=True)
    submit_info = RichTextField(blank=True)
    thanks_info = RichTextField(blank=True)

    search_fields = Page.search_fields + (
        index.SearchField('intro'),
    )

    subpage_types = ['portal_pages.CaseStudyPage']

    @route(r'^$')
    def base(self, request):
        return TemplateResponse(
            request,
            self.get_template(request),
            self.get_context(request)
github LUKKIEN / wagtailsocialfeed / wagtailsocialfeed / models.py View on Github external
self.external_id,
            self.posted
        )

    def get_content(self):
        if not hasattr(self, '_feeditem'):
            item_cls = FeedItemFactory.get_class(self.config.source)
            self._feeditem = item_cls.from_moderated(self)
        return self._feeditem

    @cached_property
    def type(self):
        return self.config.source


class SocialFeedPage(Page):
    feedconfig = models.ForeignKey(SocialFeedConfiguration,
                                   blank=True,
                                   null=True,
                                   on_delete=models.PROTECT,
                                   help_text=_("Leave blank to show all the feeds."))

    content_panels = Page.content_panels + [
        FieldPanel('feedconfig'),
    ]

    def get_context(self, request, *args, **kwargs):
        context = super(SocialFeedPage,
                        self).get_context(request, *args, **kwargs)
        feed = None
        if self.feedconfig:
            feed = get_feed_items(self.feedconfig)
github barseghyanartur / django-fobi / examples / wagtaildemo / demo / models.py View on Github external
FieldPanel('body', classname="full"),
    MultiFieldPanel(ContactFields.panels, "Contact"),
]

ContactPage.promote_panels = Page.promote_panels + [
    ImageChooserPanel('feed_image'),
]


# Event index page

class EventIndexPageRelatedLink(Orderable, RelatedLink):
    page = ParentalKey('demo.EventIndexPage', related_name='related_links')


class EventIndexPage(Page):
    intro = RichTextField(blank=True)

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

    api_fields = ['intro', 'related_links']

    @property
    def events(self):
        # Get list of live event pages that are descendants of this page
        events = EventPage.objects.live().descendant_of(self)

        # Filter events list to get ones that are either
        # running now or start in the future
        events = events.filter(date_from__gte=date.today())
github ghostwords / localore / localore / about / models.py View on Github external
from blog.models import RelatedLink
from localore_core.models import LocalorePromoteFields
from productions.models import PersonField, ProductionPage


class AboutMissionPageRelatedLink(Orderable, RelatedLink):
    page = ParentalKey('AboutMissionPage', related_name='related_links')


class AboutMissionPage(Page, LocalorePromoteFields):
    subtitle = models.CharField(max_length=255, blank=True)
    description = RichTextField()
    org_description = RichTextField(verbose_name="Organizational Description")

    search_fields = Page.search_fields + [
        index.SearchField('subtitle', partial_match=True),
        index.SearchField('description', partial_match=True),
        index.SearchField('org_description', partial_match=True),
    ]

    content_panels = Page.content_panels + [
        FieldPanel('subtitle', classname='full'),
        FieldPanel('description', classname='full'),
        FieldPanel('org_description', classname='full'),
        InlinePanel('related_links', label="Related links"),
    ]

    promote_panels = LocalorePromoteFields.promote_panels

    parent_page_types = ['home.HomePage', 'localore_admin.PageAlias']
    subpage_types = []
github rapidpro / rapidpro-community-portal / portal_pages / models.py View on Github external
def clean(self):
        possible_pages = [self.target_page, self.target_page_external]
        page_count = sum(1 for p in possible_pages if p)
        if page_count != 1:
            raise ValidationError('Please complete either target page or target page external, but not both.')

HighlightItem.panels = [
    FieldPanel('title'),
    PageChooserPanel('target_page'),
    FieldPanel('target_page_external'),
    FieldPanel('blurb'),
    ImageChooserPanel('icon'),
]


class CMSPage(Page, TopImage):
    body = RichTextField(blank=True, default='')
    iframe = models.CharField(max_length=255, blank=True, null=True) #Extremely unsafe: Fix it ASAP

CMSPage.content_panels = [
    FieldPanel('title'),
    FieldPanel('body'),
    FieldPanel('iframe'),
    MultiFieldPanel(TopImage.panels, "hero image"),
]


class TechChangePage(Page, TopImage):
    body = RichTextField(blank=True, default='')
    tech_change_link = models.CharField(max_length=255)

TechChangePage.content_panels = [
github CIGIHub / opencanada / people / models.py View on Github external
return "{} {}".format(self.first_name, self.last_name)

    @property
    def last_comma_first_name(self):
        return "{}, {}".format(self.last_name, self.first_name)

    @property
    def display_twitter_handle(self):
        if self.twitter_handle:
            return self.twitter_handle[1:]
        return self.twitter_handle

    def __str__(self):
        return "{} {} - {}".format(self.first_name, self.last_name, self.email)

    content_panels = Page.content_panels + [
        FieldPanel('first_name'),
        FieldPanel('last_name'),
        FieldPanel('email'),
        FieldPanel('twitter_handle'),
        RichTextFieldPanel('short_bio'),
        RichTextFieldPanel('long_bio'),
        ImageChooserPanel('headshot'),
    ]

    promote_panels = Page.promote_panels + [
        MultiFieldPanel(
            [
                FieldPanel('featured'),
            ],
            heading="Featuring Settings"
        )
github TakwimuAfrica / Takwimu / takwimu / models.py View on Github external
from django.db import models
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
from wagtail.wagtailcore import blocks
from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore.models import Page
from wagtail.wagtailimages.blocks import ImageChooserBlock
from wagtail.wagtailsearch import index
from wazimap.models import Geography


class ReportPage(Page):
    '''
    Geography / Country Report Page
    '''
    date = models.DateField("Post date")
    geo = models.ForeignKey(Geography, on_delete=models.SET_NULL, blank=True, null=True)
    body = StreamField([
        ('heading', blocks.CharBlock()),
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
    ])

    # Search index configuration

    search_fields = Page.search_fields + [
        index.SearchField('body'),
        index.FilterField('date'),
github torchbox / wagtailapi / wagtailapi / api.py View on Github external
def do_descendant_of_filter(self, request, queryset):
        if 'descendant_of' in request.GET:
            if getattr(queryset, '_filtered_by_child_of', False):
                raise self.BadRequestError("filtering by descendant_of with child_of is not supported")
            try:
                ancestor_page_id = int(request.GET['descendant_of'])
                assert ancestor_page_id >= 0
            except (ValueError, AssertionError):
                raise self.BadRequestError("descendant_of must be a positive integer")

            try:
                ancestor_page = self.get_queryset(request).get(id=ancestor_page_id)
                return queryset.descendant_of(ancestor_page)
            except Page.DoesNotExist:
                raise self.BadRequestError("ancestor page doesn't exist")

        return queryset
github liqd / a4-opin / projects / models.py View on Github external
'teaser_sl',
        'teaser_da',
    )

    translated_title = TranslatedField(
        'title_de',
        'title_it',
        'title',
        'title_fr',
        'title_sv',
        'title_sl',
        'title_da',
    )


class ProjectsPage(Page):
    title_en = models.CharField(max_length=255, blank=True)
    title_de = models.CharField(max_length=255, blank=True)
    title_it = models.CharField(max_length=255, blank=True)
    title_fr = models.CharField(max_length=255, blank=True)
    title_sv = models.CharField(max_length=255, blank=True)
    title_sl = models.CharField(max_length=255, blank=True)
    title_da = models.CharField(max_length=255, blank=True)

    @property
    def projects(self):
        projects = ProjectPage.objects.all()
        return projects

    translated_title = TranslatedField(
        'title_de',
        'title_it',