2017-11-02 22:20:55 +00:00
|
|
|
"""
|
|
|
|
Django settings for etesync_server project.
|
|
|
|
|
2018-05-01 15:46:50 +00:00
|
|
|
Generated by 'django-admin startproject' using Django 2.0.5.
|
2017-11-02 22:20:55 +00:00
|
|
|
|
|
|
|
For more information on this file, see
|
2018-05-01 15:46:50 +00:00
|
|
|
https://docs.djangoproject.com/en/2.0/topics/settings/
|
2017-11-02 22:20:55 +00:00
|
|
|
|
|
|
|
For the full list of settings and their values, see
|
2018-05-01 15:46:50 +00:00
|
|
|
https://docs.djangoproject.com/en/2.0/ref/settings/
|
2017-11-02 22:20:55 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
2019-05-01 10:40:48 +00:00
|
|
|
import configparser
|
2018-02-18 04:19:29 +00:00
|
|
|
from .utils import get_secret_from_file
|
2017-11-02 22:20:55 +00:00
|
|
|
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
2018-05-01 15:46:50 +00:00
|
|
|
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
|
2017-11-02 22:20:55 +00:00
|
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
2018-02-18 04:19:29 +00:00
|
|
|
# See secret.py for how this is generated; uses a file 'secret.txt' in the root
|
|
|
|
# directory
|
2018-10-29 22:23:43 +00:00
|
|
|
SECRET_FILE = os.path.join(BASE_DIR, "secret.txt")
|
2017-11-02 22:20:55 +00:00
|
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
|
DEBUG = False
|
|
|
|
|
|
|
|
ALLOWED_HOSTS = []
|
|
|
|
|
2019-05-01 10:40:48 +00:00
|
|
|
# Database
|
|
|
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
|
|
'NAME': os.environ.get('ETESYNC_DB_PATH',
|
|
|
|
os.path.join(BASE_DIR, 'db.sqlite3')),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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') } }
|
|
|
|
|
2017-11-02 22:20:55 +00:00
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
|
|
|
'django.contrib.admin',
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
2018-06-28 15:37:21 +00:00
|
|
|
'corsheaders',
|
2017-11-02 22:20:55 +00:00
|
|
|
'rest_framework',
|
|
|
|
'rest_framework.authtoken',
|
|
|
|
'journal.apps.JournalConfig',
|
|
|
|
]
|
|
|
|
|
|
|
|
MIDDLEWARE = [
|
|
|
|
'django.middleware.security.SecurityMiddleware',
|
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
2018-06-28 15:37:21 +00:00
|
|
|
'corsheaders.middleware.CorsMiddleware',
|
2017-11-02 22:20:55 +00:00
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
|
|
]
|
|
|
|
|
|
|
|
ROOT_URLCONF = 'etesync_server.urls'
|
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
'DIRS': [],
|
|
|
|
'APP_DIRS': True,
|
|
|
|
'OPTIONS': {
|
|
|
|
'context_processors': [
|
|
|
|
'django.template.context_processors.debug',
|
|
|
|
'django.template.context_processors.request',
|
|
|
|
'django.contrib.auth.context_processors.auth',
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
WSGI_APPLICATION = 'etesync_server.wsgi.application'
|
|
|
|
|
|
|
|
|
|
|
|
# Password validation
|
2018-05-01 15:46:50 +00:00
|
|
|
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
|
2017-11-02 22:20:55 +00:00
|
|
|
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
|
|
{
|
2018-05-01 15:46:50 +00:00
|
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
2017-11-02 22:20:55 +00:00
|
|
|
},
|
|
|
|
{
|
2018-05-01 15:46:50 +00:00
|
|
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
2017-11-02 22:20:55 +00:00
|
|
|
},
|
|
|
|
{
|
2018-05-01 15:46:50 +00:00
|
|
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
2017-11-02 22:20:55 +00:00
|
|
|
},
|
|
|
|
{
|
2018-05-01 15:46:50 +00:00
|
|
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
2017-11-02 22:20:55 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# Internationalization
|
2018-05-01 15:46:50 +00:00
|
|
|
# https://docs.djangoproject.com/en/2.0/topics/i18n/
|
2017-11-02 22:20:55 +00:00
|
|
|
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
USE_L10N = True
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
2018-05-01 15:46:50 +00:00
|
|
|
# https://docs.djangoproject.com/en/2.0/howto/static-files/
|
2017-11-02 22:20:55 +00:00
|
|
|
|
|
|
|
STATIC_URL = '/static/'
|
2018-11-01 11:51:26 +00:00
|
|
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
|
2017-11-02 22:20:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
JOURNAL_API_PERMISSIONS = (
|
|
|
|
'rest_framework.permissions.IsAuthenticated',
|
|
|
|
)
|
2018-06-28 15:37:21 +00:00
|
|
|
|
|
|
|
# Cors
|
|
|
|
CORS_ORIGIN_ALLOW_ALL = True
|
2018-10-29 22:25:35 +00:00
|
|
|
|
|
|
|
# Make an `etesync_site_settings` module available to override settings.
|
|
|
|
try:
|
|
|
|
from etesync_site_settings import *
|
|
|
|
except ImportError:
|
|
|
|
pass
|
2018-10-29 22:26:13 +00:00
|
|
|
|
|
|
|
if 'SECRET_KEY' not in locals():
|
|
|
|
SECRET_KEY = get_secret_from_file(SECRET_FILE)
|