Remove instruments from CMS explorer

This commit is contained in:
Ramon Wenger 2022-04-13 14:11:57 +02:00
parent 49ef1a21f5
commit ddb7bb9dbc
2 changed files with 10 additions and 10 deletions

View File

@ -1,10 +0,0 @@
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

View File

@ -2,6 +2,10 @@ import wagtail.admin.rich_text.editors.draftail.features as draftail_features
from wagtail.admin.rich_text.converters.html_to_contentstate import InlineStyleElementHandler
from wagtail.core import hooks
from basicknowledge.models import BasicKnowledge
from books.models import ContentBlockSnapshot
# 1. Use the register_rich_text_features hook.
@hooks.register('register_rich_text_features')
def register_brand_feature(features):
@ -41,6 +45,7 @@ def register_brand_feature(features):
# on rich text fields that do not specify an explicit 'features' list
features.default_features.append(feature_name)
@hooks.register('register_rich_text_features')
def register_secondary_feature(features):
"""
@ -78,3 +83,8 @@ def register_secondary_feature(features):
# 6. (optional) Add the feature to the default features list to make it available
# on rich text fields that do not specify an explicit 'features' list
features.default_features.append(feature_name)
@hooks.register('construct_explorer_page_queryset')
def remove_page_types_from_menu(parent_page, pages, request):
return pages.not_type(ContentBlockSnapshot).not_type(BasicKnowledge).exclude(contentblock__user_created=True)