How to use the puput.models.BlogPage function in puput

To help you get started, we’ve selected a few puput 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 APSL / puput / puput / feeds.py View on Github external
def __call__(self, request, *args, **kwargs):
        if request.resolver_match.url_name == 'blog_page_feed_slug':
            self.blog_page = BlogPage.extra.get_by_path(kwargs['blog_path'])
            if not self.blog_page:
                raise http.Http404
        else:
            self.blog_page = BlogPage.objects.first()
        self.request = request
        return super(BlogPageFeed, self).__call__(request, *args, **kwargs)
github APSL / puput / puput / models.py View on Github external
def get_context(self, request, *args, **kwargs):
        context = super(BlogPage, self).get_context(request, *args, **kwargs)
        context['entries'] = self.entries
        context['blog_page'] = self
        context['search_type'] = getattr(self, 'search_type', "")
        context['search_term'] = getattr(self, 'search_term', "")
        return context
github bashu / wagtail-metadata-mixin / example / localsite / apps.py View on Github external
def ready(self):
        try:
            from puput.models import BlogPage

            post_init.connect(handle_blog_model, sender=BlogPage)

        except:  # noqa
            pass  # shit happens
github climu / openstudyroom / home / models.py View on Github external
]

class LeftSidebarPage(MenuPage):
    body = StreamField(MyStreamBlock(), blank=True)

    content_panels = Page.content_panels + [

        StreamFieldPanel('body'),
    ]

class StreamFieldEntryPage(EntryPage):
    streamfield = StreamField(MyStreamBlock(), blank=True)
    content_panels = EntryPage.content_panels + [
        StreamFieldPanel('streamfield')
    ]
BlogPage.subpage_types.append(StreamFieldEntryPage)


# Let everyone know when a new page is published
def send_to_discord(sender, **kwargs):
    instance = kwargs['instance']
    # Only post new post. No updates.
    if instance.first_published_at != instance.last_published_at:
        return

    if settings.DEBUG:
        return
    else:
        with open('/etc/discord_hook_url.txt') as f:
            discord_url = f.read().strip()

    excerpt = render_to_string(
github APSL / wordpress-to-puput / wordpress2puput / management / commands / wp2puput.py View on Github external
def get_blog_page(self, slug, title):
        # Create blog page
        try:
            self.blogpage = BlogPage.objects.get(slug=slug)
        except BlogPage.DoesNotExist:
            # Get root page
            rootpage = Page.objects.first()

            # Set site root page as root site page
            site = Site.objects.first()
            site.root_page = rootpage
            site.save()

            # Get blogpage content type
            self.blogpage = BlogPage(title=title, slug=slug)
            rootpage.add_child(instance=self.blogpage)
            revision = rootpage.save_revision()
            revision.publish()