Add 'allowed blocks' property for room entry

This commit is contained in:
Ramon Wenger 2018-09-24 17:02:57 +02:00
parent fb5b77e7f2
commit 9a89fa874b
1 changed files with 14 additions and 1 deletions

View File

@ -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',