skillbox/server/books/management/commands/print_lernziele_order.py

29 lines
940 B
Python

import json
from logging import getLogger
from django.core.management import BaseCommand
from books.management.commands.migrate_objectives_to_content import create_text_in_content_block, \
create_content_block_snapshot_from_objective, \
create_content_block_contents
from books.models import Chapter, ObjectiveGroupSnapshot, ContentBlockSnapshot, Snapshot, ChapterSnapshot
from books.models import ContentBlock
from books.models import Module
from objectives.models import Objective, ObjectiveSnapshot, ObjectiveGroup
logger = getLogger(__name__)
class Command(BaseCommand):
def handle(self, *args, **options):
analyze()
def analyze():
for chapter in Chapter.objects.filter(title="Lernziele"):
print(f"Chapter: {chapter.get_parent().title} {[cb.title for cb in ContentBlock.get_by_parent(chapter)]}")
# [cb.delete() for cb in ContentBlock.get_by_parent(chapter)]
# chapter.delete()