From 9a89fa874bcc45e2fd0e097968f1cd481a7ade9d Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Mon, 24 Sep 2018 17:02:57 +0200 Subject: [PATCH] Add 'allowed blocks' property for room entry --- server/book/schema/mutations.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server/book/schema/mutations.py b/server/book/schema/mutations.py index eaee86ef..a00f9867 100644 --- a/server/book/schema/mutations.py +++ b/server/book/schema/mutations.py @@ -18,12 +18,25 @@ def newlines_to_paragraphs(text): return '\n'.join(paragraphs) -def handle_content_blocks(content_data): +ALLOWED_BLOCKS = ( + 'text_block', + 'student_entry', + 'image_url_block', + 'link_block', + 'video_block', + 'document_block', +) + + +def handle_content_blocks(content_data, allowed_blocks=ALLOWED_BLOCKS): new_contents = [] for content in content_data: # todo: add all the content blocks # todo: sanitize user inputs! + if content['type'] not in allowed_blocks: + continue + if content['type'] == 'text_block': new_contents.append({ 'type': 'text_block',