skillbox/server/books/wagtail_hooks.py

11 lines
368 B
Python

from wagtail.core import hooks
from .models import ContentBlockSnapshot
@hooks.register('construct_explorer_page_queryset')
def remove_user_created_content_blocks_from_menu(parent_page, pages, request):
if parent_page.content_type.model == 'chapter':
return pages.not_type(ContentBlockSnapshot).exclude(contentblock__user_created=True)
return pages