subject.curriculum.new in select list
[redakcja.git] / apps / build / management / commands / build.py
index d87d3b4..c275144 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 import os
 from subprocess import call
 from optparse import make_option
 import os
 from subprocess import call
 from optparse import make_option
@@ -7,26 +8,36 @@ from django.core.management import call_command
 
 
 class Command(BaseCommand):
 
 
 class Command(BaseCommand):
-    
+
     option_list = BaseCommand.option_list + (
     option_list = BaseCommand.option_list + (
-        make_option('--node-bin-path',
+        make_option(
+            '--node-bin-path',
             action='store',
             dest='node_bin_path',
             type='string',
             default=None,
             help='Path to node binary'),
             action='store',
             dest='node_bin_path',
             type='string',
             default=None,
             help='Path to node binary'),
-        make_option('--npm-bin',
+        make_option(
+            '--npm-bin',
             action='store',
             dest='npm_bin',
             type='string',
             default='npm',
             help='Path to npm binary'),
             action='store',
             dest='npm_bin',
             type='string',
             default='npm',
             help='Path to npm binary'),
-        make_option('--editor-npm-env',
+        make_option(
+            '--editor-npm-env',
             action='store',
             dest='editor_npm_env',
             type='string',
             default=None,
             help='Destination path of npm environment, defaults to ./node_modules'),
             action='store',
             dest='editor_npm_env',
             type='string',
             default=None,
             help='Destination path of npm environment, defaults to ./node_modules'),
+        make_option(
+            '--editor-optimize',
+            action='store',
+            dest='editor_optimize',
+            type='string',
+            default=None,
+            help='Optimization strategy for editor build'),
         )
 
     def handle(self, **options):
         )
 
     def handle(self, **options):
@@ -42,7 +53,7 @@ class Command(BaseCommand):
             assert os.path.isdir(npm_env)
             os.symlink(npm_env, os.path.join(rng_base_dir, 'node_modules'))
         try:
             assert os.path.isdir(npm_env)
             os.symlink(npm_env, os.path.join(rng_base_dir, 'node_modules'))
         try:
-            call([options['npm_bin'], 'install'], cwd = rng_base_dir)
+            call([options['npm_bin'], 'install'], cwd=rng_base_dir)
         except OSError:
             raise CommandError('Something went wrong, propably npm binary not found. Tried: %s' % options['npm_bin'])
 
         except OSError:
             raise CommandError('Something went wrong, propably npm binary not found. Tried: %s' % options['npm_bin'])
 
@@ -50,6 +61,9 @@ class Command(BaseCommand):
         if options['node_bin_path']:
             # grunt needs npm binary to be foundable in PATH
             os.environ['PATH'] = '%s:%s' % (options['node_bin_path'], os.environ['PATH'])
         if options['node_bin_path']:
             # grunt needs npm binary to be foundable in PATH
             os.environ['PATH'] = '%s:%s' % (options['node_bin_path'], os.environ['PATH'])
-        call(['./node_modules/.bin/grunt', 'build', '--output-dir=%s' % build_dir], cwd = rng_base_dir)
+        args = ['./node_modules/.bin/grunt', 'build', '--output-dir=%s' % build_dir]
+        if options['editor_optimize']:
+            args.append('--optimize=%s' % options['editor_optimize'])
+        call(args, cwd=rng_base_dir)
 
 
-        call_command('collectstatic', interactive = False, ignore_patterns = ['editor'])
+        call_command('collectstatic', interactive=False, ignore_patterns=['editor'])