Add export script for instruments
This commit is contained in:
parent
9db8519869
commit
ad9e147ec1
|
|
@ -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'<h3>{c.value.get("text")}</h3>'),
|
||||
'section_title': lambda c: print(f'<h2>{c.value.get("text")}</h2>'),
|
||||
'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('<html><head></head><body>')
|
||||
for i in BasicKnowledge.objects.live():
|
||||
print(f'<h1>{i.title}</h1>')
|
||||
for c in i.contents:
|
||||
action = actions.get(c.block_type, lambda c: print(f'==={c.block_type}==='))
|
||||
action(c)
|
||||
print('</body></html>')
|
||||
|
||||
Loading…
Reference in New Issue