Add slugs argument to export instruments command

This commit is contained in:
Ramon Wenger 2022-11-30 16:55:20 +01:00
parent f071e85863
commit ebc4ca50ae
1 changed files with 4 additions and 2 deletions

View File

@ -18,13 +18,15 @@ actions = {
class Command(BaseCommand): class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('--slugs', nargs='+', type=str)
def handle(self, *args, **options): def handle(self, *args, **options):
# todo: only published after X: Page.last_published_at > X # todo: only published after X: Page.last_published_at > X
print('<html><head></head><body>') print('<html><head></head><body>')
for i in BasicKnowledge.objects.live().filter(last_published_at__gt=date(2022, 4, 7)): for i in BasicKnowledge.objects.live().filter(slug__in=options['slugs']):
print(f'<h1>{i.title}</h1>') print(f'<h1>{i.title}</h1>')
for c in i.contents: for c in i.contents:
action = actions.get(c.block_type, lambda c: print(f'==={c.block_type}===')) action = actions.get(c.block_type, lambda c: print(f'==={c.block_type}==='))
action(c) action(c)
print('</body></html>') print('</body></html>')