diff --git a/etesync-server.ini.example b/etesync-server.ini.example index 3b8b518..424a26d 100644 --- a/etesync-server.ini.example +++ b/etesync-server.ini.example @@ -1,6 +1,11 @@ [global] secret_file = secret.txt debug = false +;Advanced options, only uncomment if you know what you're doing: +;static_root = /path/to/static +;static_url = /static/ +;language_code = en-us +;time_zone = UTC [allowed_hosts] allowed_host1 = example.com diff --git a/etesync_server/settings.py b/etesync_server/settings.py index cfe339f..ab7ff8b 100644 --- a/etesync_server/settings.py +++ b/etesync_server/settings.py @@ -43,23 +43,6 @@ DATABASES = { } - -# Define where to find configuration files -config_locations = ['etesync-server.ini', '/etc/etesync-server/etesync-server.ini'] -# Use config file if present -if any(os.path.isfile(x) for x in config_locations): - config = configparser.ConfigParser() - config.read(config_locations) - - SECRET_FILE = config['global']['secret_file'] - - DEBUG = config['global'].getboolean('debug') - - ALLOWED_HOSTS = [y for x, y in config.items('allowed_hosts')] - - DATABASES = { 'default': { x.upper(): y for x, y in config.items('database') } } - - # Application definition INSTALLED_APPS = [ @@ -149,6 +132,28 @@ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static/') +# Define where to find configuration files +config_locations = ['etesync-server.ini', '/etc/etesync-server/etesync-server.ini'] +# Use config file if present +if any(os.path.isfile(x) for x in config_locations): + config = configparser.ConfigParser() + config.read(config_locations) + + section = config['global'] + + SECRET_FILE = section.get('secret_file', SECRET_FILE) + STATIC_ROOT = section.get('static_root', STATIC_ROOT) + STATIC_URL = section.get('static_url', STATIC_URL) + LANGUAGE_CODE = section.get('language_code', LANGUAGE_CODE) + TIME_ZONE = section.get('time_zone', TIME_ZONE) + DEBUG = section.getboolean('debug', DEBUG) + + if 'allowed_hosts' in config: + ALLOWED_HOSTS = [y for x, y in config.items('allowed_hosts')] + + if 'database' in config: + DATABASES = { 'default': { x.upper(): y for x, y in config.items('database') } } + JOURNAL_API_PERMISSIONS = ( 'rest_framework.permissions.IsAuthenticated', )