X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/bac318ce6c0be90f72220f3676c919ed0662fff8..cd8813f7be8e11b18b7e23d217dd6404e26d07d4:/catalogue/management/commands/importlessons.py diff --git a/catalogue/management/commands/importlessons.py b/catalogue/management/commands/importlessons.py index 6efd246..6252fb5 100755 --- a/catalogue/management/commands/importlessons.py +++ b/catalogue/management/commands/importlessons.py @@ -11,6 +11,7 @@ from django.core.management.base import BaseCommand from django.core.management.color import color_style from django.core.files import File +from librarian import IOFile from catalogue.models import Lesson #from search import Index @@ -26,8 +27,13 @@ class Command(BaseCommand): def import_book(self, file_path, options): verbose = options.get('verbose') - with open(file_path) as f: - lesson = Lesson.publish(f) + iofile = IOFile.from_filename(file_path) + basename, ext = file_path.rsplit('.', 1) + if os.path.isdir(basename): + for att_name in os.listdir(basename): + iofile.attachments[att_name] = IOFile.from_filename( + os.path.join(basename, att_name)) + lesson = Lesson.publish(iofile) def handle(self, *directories, **options): from django.db import transaction