Remove content blocks belonging to snapshots from CMS explorer

This commit is contained in:
Ramon Wenger 2022-04-05 13:16:09 +02:00
parent 3c6160a7bb
commit d09844a67b
1 changed files with 2 additions and 3 deletions

View File

@ -1,11 +1,10 @@
from wagtail.core import hooks
from .models import ContentBlock
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':
content_block_ids = ContentBlock.get_by_parent(parent_page.specific).exclude(user_created=True).values_list('id', flat=True)
return pages.filter(id__in=content_block_ids)
return pages.not_type(ContentBlockSnapshot).exclude(contentblock__user_created=True)
return pages