diff --git a/tests/test_ctl.py b/tests/test_ctl.py index 8ce5785f9..1a0d147d4 100644 --- a/tests/test_ctl.py +++ b/tests/test_ctl.py @@ -10,7 +10,7 @@ from wcs.workflows import Workflow from wcs.wf.jump import JumpWorkflowStatusItem from wcs.fields import StringField, EmailField import wcs.qommon.ctl -from wcs.ctl.collectstatic import CmdCollectStatic +from wcs.qommon.management.commands.collectstatic import Command as CmdCollectStatic from wcs.ctl.process_bounce import CmdProcessBounce from wcs.ctl.wipe_data import CmdWipeData from wcs.ctl.trigger_jumps import select_and_jump_formdata diff --git a/wcs/ctl/collectstatic.py b/wcs/qommon/management/commands/collectstatic.py similarity index 69% rename from wcs/ctl/collectstatic.py rename to wcs/qommon/management/commands/collectstatic.py index 2877d3406..d7fe8a451 100644 --- a/wcs/ctl/collectstatic.py +++ b/wcs/qommon/management/commands/collectstatic.py @@ -1,5 +1,5 @@ # w.c.s. - web application for online forms -# Copyright (C) 2005-2016 Entr'ouvert +# Copyright (C) 2005-2017 Entr'ouvert # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,33 +17,31 @@ import os import shutil -from qommon.ctl import Command, make_option +from django.core.management.base import BaseCommand +from qommon.publisher import get_publisher_class +class Command(BaseCommand): + help = "Collect static files in a single location." -class CmdCollectStatic(Command): - name = 'collectstatic' + def add_arguments(self, parser): + parser.add_argument('-c', '--clear', + action='store_true', dest='clear', default=False, + help="Clear the existing files using the storage " + "before trying to copy or link the original file.") + parser.add_argument('-l', '--link', + action='store_true', dest='link', default=False, + help="Create a symbolic link to each file instead of copying.") - def __init__(self): - Command.__init__(self, [ - make_option('-c', '--clear', action='store_true', - dest='clear', default=False), - make_option('-l', '--link', action='store_true', - dest='link', default=False), - ]) - - def execute(self, base_options, sub_options, args): - import publisher - publisher.WcsPublisher.configure(self.config) - publisher.WcsPublisher.ERROR_LOG = None - pub = publisher.WcsPublisher.create_publisher( - register_cron=False, register_tld_names=False) + def handle(self, **options): + Publisher = get_publisher_class() + Publisher.ERROR_LOG = None + pub = Publisher.create_publisher() return self.collectstatic(pub, - clear=sub_options.clear, link=sub_options.link) + clear=options['clear'], link=options['link']) @classmethod def collectstatic(cls, pub, clear=False, link=False): - from wcs.root import StaticsDirectory - root_directory_class = StaticsDirectory + root_directory_class = pub.root_directory_class.static static_dir = os.path.join(pub.app_dir, 'collectstatic') if clear and os.path.exists(static_dir): shutil.rmtree(static_dir) @@ -67,5 +65,3 @@ class CmdCollectStatic(Command): os.symlink(os.path.join(basedir, filename), dst_filename) else: shutil.copy(os.path.join(basedir, filename), dst_filename) - -CmdCollectStatic.register() diff --git a/wcs/settings.py b/wcs/settings.py index ffbc99959..d7c76df05 100644 --- a/wcs/settings.py +++ b/wcs/settings.py @@ -131,10 +131,10 @@ INSTALLED_APPS = ( #'django.contrib.sessions', #'django.contrib.sites', #'django.contrib.messages', - 'django.contrib.staticfiles', #'django.contrib.admin', 'gadjo', 'wcs.qommon', + 'django.contrib.staticfiles', ) WCS_LEGACY_CONFIG_FILE = None