1 # -*- coding: utf-8 -*-
2 # This file is part of EduMed, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from optparse import make_option
8 from django.core.management.base import BaseCommand
11 class Command(BaseCommand):
12 help = 'Republishes all lessons.'
14 option_list = BaseCommand.option_list + (
15 make_option('--exclude', dest='exclude', metavar="PATH", default=None,
16 help='PATH to file with excluded lesson slugs.'),
17 make_option('--ignore-incomplete', action='store_true', dest='ignore_incomplete', default=False,
18 help='Attachments dir path.'),
19 make_option('--dont-repackage', action='store_false', dest='repackage', default=True,
20 help='Don\'t refresh level packages.'),
23 def handle(self, **options):
24 from catalogue.models import Lesson
25 from curriculum.models import Level
27 lessons = Lesson.objects.order_by('slug')
29 if options.get('exclude'):
30 slugs = [line.strip() for line in open(options['exclude'])]
31 lessons = lessons.exclude(slug__in=slugs)
33 for lesson in lessons:
35 print 'Republishing: %s' % lesson.slug
37 lesson.republish(repackage_level=False)
38 except librarian.ParseError as e:
39 print '!!!!!! PARSE ERROR !!!!!!'
42 if options.get('repackage'):
43 print 'Rebuilding levels...'
44 for level in Level.objects.all():
46 level.build_packages()