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
7 from django.core.management.base import BaseCommand
10 class Command(BaseCommand):
11 help = 'Republishes all lessons.'
13 option_list = BaseCommand.option_list + (
14 make_option('--exclude', dest='exclude', metavar="PATH", default=None,
15 help='PATH to file with excluded lesson slugs.'),
16 make_option('--ignore-incomplete', action='store_true', dest='ignore_incomplete', default=False,
17 help='Attachments dir path.'),
18 make_option('--dont-repackage', action='store_false', dest='repackage', default=True,
19 help='Don\'t refresh level packages.'),
22 def handle(self, **options):
23 from catalogue.models import Lesson
24 from curriculum.models import Level
26 lessons = Lesson.objects.order_by('slug')
28 if options.get('exclude'):
29 slugs = [line.strip() for line in open(options['exclude'])]
30 lessons = lessons.exclude(slug__in=slugs)
32 for lesson in lessons:
34 print 'Republishing: %s' % lesson.slug
36 lesson.republish(repackage_level=False)
37 # except BaseException as e:
38 # print '!!!!!! EXCEPTION !!!!!!'
41 print 'Rebuilding levels...'
42 for level in Level.objects.all():
43 level.build_packages()