From e6e64ebad1f617d85e9fe3be7e7a1b1820408f0a Mon Sep 17 00:00:00 2001 From: joeyjurjens Date: Tue, 27 Oct 2020 01:18:37 +0100 Subject: [PATCH] Add the ability to have all blocks closed by default instead --- wagtail_react_streamfield/monkey_patch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wagtail_react_streamfield/monkey_patch.py b/wagtail_react_streamfield/monkey_patch.py index f65c4a3..490b1d9 100644 --- a/wagtail_react_streamfield/monkey_patch.py +++ b/wagtail_react_streamfield/monkey_patch.py @@ -1,5 +1,7 @@ from functools import wraps +from django.conf import settings + from wagtail.core.blocks import ( BlockField, Block, BaseStreamBlock, ListBlock, BaseStructBlock, FieldBlock, StaticBlock) @@ -67,7 +69,7 @@ def patch(): 'FIELD_NAME_TEMPLATE', 'get_default', 'get_children_errors', 'prepare_value', 'get_instance_html', 'definition', 'html_declarations', 'all_html_declarations') - Block._meta_class.closed = False + Block._meta_class.closed = getattr(settings, "BLOCK_CLOSED_BY_DEFAULT", False) _patch_with(BaseStreamBlock, NewBaseStreamBlock, 'definition', 'sorted_child_blocks', 'render_list_member', 'html_declarations', 'js_initializer', 'prepare_value',