Changed name of '--development' option and name of the respective directory. Fixed #2001

This commit is contained in:
Norman Jäckel 2016-02-27 18:27:03 +01:00
parent 8d1de6923b
commit ca3cfae8b3
7 changed files with 42 additions and 35 deletions

4
.gitignore vendored
View File

@ -12,8 +12,8 @@
node_modules/*
bower_components/*
# Development user data (settings, database, media, search index, static files)
development/*
# Local user data (settings, database, media, search index, static files)
personal_data/*
openslides/static/*
# Package building/IDE

View File

@ -56,7 +56,8 @@ Other:
- Updated to Bootstrap 3.
- Used SockJS for automatic update of AngularJS driven single page frontend.
- Refactored plugin API.
- Refactored start script and management commands.
- Refactored start script and management commands. Changed command line
options and path for local installation.
- Refactored tests.
- Used Bower and gulp to manage third party JavaScript and Cascading Style
Sheets libraries.

View File

@ -149,6 +149,12 @@ To get help on the command line options run::
openslides --help
You can store settings, database and other personal files in a local
subdirectory and use these files e. g. if you want to run multiple
instances of OpenSlides::
openslides --local-installation
V. Development
==============
@ -214,7 +220,7 @@ Installation and start of the development version
python manage.py start
This will create a new development directoy with settings.py and database.
This will create a new directoy with settings.py and database.
To get help on the command-line options run::

View File

@ -10,8 +10,8 @@ from openslides.utils.main import (
ExceptionArgumentParser,
UnknownCommand,
get_default_settings_path,
get_development_settings_path,
is_development,
get_local_settings_path,
is_local_installation,
setup_django_settings_module,
start_browser,
write_settings,
@ -32,8 +32,8 @@ def main():
if unknown_command:
# Run a command, that is defined by the django management api
development = is_development()
setup_django_settings_module(development=development)
local_installation = is_local_installation()
setup_django_settings_module(local_installation=local_installation)
execute_from_command_line(sys.argv)
else:
# Run a command that is defined here
@ -45,7 +45,7 @@ def get_parser():
"""
Parses all command line arguments.
"""
if len(sys.argv) == 1 and not is_development():
if len(sys.argv) == 1 and not is_local_installation():
sys.argv.append('start')
# Init parser
@ -104,9 +104,9 @@ def get_parser():
help='The used settings file. The file is created, if it does not exist.')
subcommand_start.set_defaults(callback=start)
subcommand_start.add_argument(
'--development',
'--local-installation',
action='store_true',
help='Option for development purposes.')
help='Store settings and user files in a local directory.')
# Subcommand createsettings
createsettings_help = 'Creates the settings file.'
@ -121,9 +121,9 @@ def get_parser():
default=None,
help='The used settings file. The file is created, even if it exists.')
subcommand_createsettings.add_argument(
'--development',
'--local-installation',
action='store_true',
help='Option for development purposes.')
help='Store settings and user files in a local directory.')
# Help text for several Django subcommands
django_subcommands = (
@ -147,11 +147,11 @@ def start(args):
Starts OpenSlides: Runs migrations and runs runserver.
"""
settings_path = args.settings_path
development = is_development()
local_installation = is_local_installation()
if settings_path is None:
if development:
settings_path = get_development_settings_path()
if local_installation:
settings_path = get_local_settings_path()
else:
settings_path = get_default_settings_path()
@ -161,7 +161,7 @@ def start(args):
# Set the django setting module and run migrations
# A manual given environment variable will be overwritten
setup_django_settings_module(settings_path, development=development)
setup_django_settings_module(settings_path, local_installation=local_installation)
execute_from_command_line(['manage.py', 'migrate'])
@ -178,14 +178,14 @@ def createsettings(args):
Creates settings for OpenSlides.
"""
settings_path = args.settings_path
development = is_development()
local_installation = is_local_installation()
context = {}
if development:
if local_installation:
if settings_path is None:
settings_path = get_development_settings_path()
settings_path = get_local_settings_path()
context = {
'openslides_user_data_path': repr(os.path.join(os.getcwd(), 'development', 'var')),
'openslides_user_data_path': repr(os.path.join(os.getcwd(), 'personal_data', 'var')),
'debug': 'True'}
settings_path = write_settings(settings_path, **context)

View File

@ -82,16 +82,16 @@ def get_default_settings_path(openslides_type=None):
return os.path.join(parent_directory, 'openslides', 'settings.py')
def get_development_settings_path():
def get_local_settings_path():
"""
Returns the path to a local development settings.
Returns the path to a local settings.
On Unix systems: 'development/var/settings.py'
On Unix systems: 'personal_data/var/settings.py'
"""
return os.path.join('development', 'var', 'settings.py')
return os.path.join('personal_data', 'var', 'settings.py')
def setup_django_settings_module(settings_path=None, development=None):
def setup_django_settings_module(settings_path=None, local_installation=None):
"""
Sets the environment variable ENVIRONMENT_VARIABLE, that means
'DJANGO_SETTINGS_MODULE', to the given settings.
@ -106,8 +106,8 @@ def setup_django_settings_module(settings_path=None, development=None):
return
if settings_path is None:
if development:
settings_path = get_development_settings_path()
if local_installation:
settings_path = get_local_settings_path()
else:
settings_path = get_default_settings_path()
@ -307,10 +307,10 @@ def translate_customizable_strings(language_code):
activate(current_language)
def is_development():
def is_local_installation():
"""
Returns True if the command is called for development.
Returns True if the command is called for a local installation
This is the case if manage.py is used, or when the --development flag is set.
This is the case if manage.py is used, or when the --local-installation flag is set.
"""
return True if '--development' in sys.argv or 'manage.py' in sys.argv[0] else False
return True if '--local-installation' in sys.argv or 'manage.py' in sys.argv[0] else False

View File

@ -2,7 +2,7 @@
source = openslides
[coverage:html]
directory = development/tmp/htmlcov
directory = personal_data/tmp/htmlcov
[flake8]
max_line_length = 150

View File

@ -55,8 +55,8 @@ class TestFunctions(TestCase):
self.assertEqual(main.get_default_settings_path(main.WINDOWS_PORTABLE_VERSION),
'portable/openslides/settings.py')
def test_get_development_settings_path(self):
self.assertEqual(main.get_development_settings_path(), os.sep.join(('development', 'var', 'settings.py')))
def test_get_local_settings_path(self):
self.assertEqual(main.get_local_settings_path(), os.sep.join(('personal_data', 'var', 'settings.py')))
def test_setup_django_settings_module(self):
main.setup_django_settings_module('test_dir_dhvnghfjdh456fzheg2f/test_path_bngjdhc756dzwncshdfnx.py')