option to skip repackage on import
authorJan Szejko <janek37@gmail.com>
Tue, 22 Nov 2016 11:43:45 +0000 (12:43 +0100)
committerJan Szejko <janek37@gmail.com>
Tue, 22 Nov 2016 11:44:28 +0000 (12:44 +0100)
catalogue/management/commands/importlessons.py

index d4733d3..6c52493 100755 (executable)
@@ -21,6 +21,8 @@ class Command(BaseCommand):
                     help='Attachments dir path.'),
         make_option('--ignore-incomplete', action='store_true', dest='ignore_incomplete', default=False,
                     help='Attachments dir path.'),
                     help='Attachments dir path.'),
         make_option('--ignore-incomplete', action='store_true', dest='ignore_incomplete', default=False,
                     help='Attachments dir path.'),
+        make_option('--dont-repackage', action='store_false', dest='repackage', default=True,
+                    help='Don\'t refresh level packages.'),
     )
     help = 'Imports lessons from the specified directories.'
     args = 'directory [directory ...]'
     )
     help = 'Imports lessons from the specified directories.'
     args = 'directory [directory ...]'
@@ -52,6 +54,8 @@ class Command(BaseCommand):
     @transaction.atomic
     def handle(self, *directories, **options):
 
     @transaction.atomic
     def handle(self, *directories, **options):
 
+        repackage = self.options.get('repackage')
+
         self.levels = set()
 
         curdir = os.path.abspath(os.curdir)
         self.levels = set()
 
         curdir = os.path.abspath(os.curdir)
@@ -69,7 +73,7 @@ class Command(BaseCommand):
                 files_imported += files_imported_dir
                 files_skipped += files_skipped_dir
 
                 files_imported += files_imported_dir
                 files_skipped += files_skipped_dir
 
-        if self.levels:
+        if self.levels and repackage:
             print "Rebuilding level packages:"
             for level in self.levels:
                 print level.name
             print "Rebuilding level packages:"
             for level in self.levels:
                 print level.name