From ad9e147ec1c5743f3dc44c4ecac255ec0402e4d0 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Tue, 12 Apr 2022 16:16:28 +0200 Subject: [PATCH] Add export script for instruments --- .../management/commands/export_instruments.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 server/core/management/commands/export_instruments.py diff --git a/server/core/management/commands/export_instruments.py b/server/core/management/commands/export_instruments.py new file mode 100644 index 00000000..b021c8b6 --- /dev/null +++ b/server/core/management/commands/export_instruments.py @@ -0,0 +1,29 @@ +from django.core.management import BaseCommand + +from basicknowledge.models import BasicKnowledge + +actions = { + 'text_block': lambda c: print(c.value.get('text')), + 'subtitle': lambda c: print(f'

{c.value.get("text")}

'), + 'section_title': lambda c: print(f'

{c.value.get("text")}

'), + 'thinglink_block': lambda c: print('===THINGLINK==='), + 'image_block': lambda c: print('===BILD==='), + 'document_block': lambda c: print('===DOCUMENT==='), + 'infogram_block': lambda c: print('===INFOGRAM==='), + 'genially_block': lambda c: print('===GENIALLY==='), + 'video_block': lambda c: print('===VIDEO==='), + 'link_block': lambda c: print(f'===LINK=== {c.value.get("text")} {c.value.get("url")}'), +} + + +class Command(BaseCommand): + def handle(self, *args, **options): + # todo: only published after X: Page.last_published_at > X + print('') + for i in BasicKnowledge.objects.live(): + print(f'

{i.title}

') + for c in i.contents: + action = actions.get(c.block_type, lambda c: print(f'==={c.block_type}===')) + action(c) + print('') +