2020-12-28 12:35:36 +01:00
|
|
|
"""
|
|
|
|
**************************************************************************
|
|
|
|
Please do not modify this file, it will be reset at the next update.
|
|
|
|
You can edit the file __FINAL_HOME_PATH__/local_settings.py and add/modify
|
|
|
|
the settings you need.
|
|
|
|
|
|
|
|
The parameters you add in local_settings.py will overwrite these,
|
|
|
|
but you can use the options and documentation in this file to find out
|
|
|
|
what can be done.
|
|
|
|
**************************************************************************
|
|
|
|
|
|
|
|
Django Settings here depends on YunoHost app settings.
|
|
|
|
"""
|
|
|
|
from pathlib import Path as __Path
|
2020-12-23 19:53:13 +01:00
|
|
|
|
2020-12-28 12:35:36 +01:00
|
|
|
from django_ynh.base_settings import * # noqa
|
|
|
|
from django_ynh.secret_key import get_or_create_secret as __get_or_create_secret
|
2020-12-23 19:53:13 +01:00
|
|
|
|
|
|
|
|
2020-12-28 12:35:36 +01:00
|
|
|
DEBUG = True # This is only the DEMO app ;) But should never be on in production!
|
2020-12-23 19:53:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
FINAL_HOME_PATH = __Path('__FINAL_HOME_PATH__') # /opt/yunohost/$app
|
|
|
|
assert FINAL_HOME_PATH.is_dir(), f'Directory not exists: {FINAL_HOME_PATH}'
|
|
|
|
|
|
|
|
FINAL_WWW_PATH = __Path('__FINAL_WWW_PATH__') # /var/www/$app
|
|
|
|
assert FINAL_WWW_PATH.is_dir(), f'Directory not exists: {FINAL_WWW_PATH}'
|
|
|
|
|
|
|
|
LOG_FILE = __Path('__LOG_FILE__') # /var/log/$app/django_ynh.log
|
|
|
|
assert LOG_FILE.is_file(), f'File not exists: {LOG_FILE}'
|
|
|
|
|
|
|
|
PATH_URL = '__PATH_URL__' # $YNH_APP_ARG_PATH
|
|
|
|
PATH_URL = PATH_URL.strip('/')
|
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
2020-12-28 18:52:29 +01:00
|
|
|
YNH_SETUP_USER = 'setup_user.setup_demo_user'
|
|
|
|
|
2020-12-28 12:35:36 +01:00
|
|
|
SECRET_KEY = __get_or_create_secret(FINAL_HOME_PATH / 'secret.txt') # /opt/yunohost/$app/secret.txt
|
2020-12-23 19:53:13 +01:00
|
|
|
|
2020-12-28 12:35:36 +01:00
|
|
|
ADMINS = (('__ADMIN__', '__ADMINMAIL__'),)
|
2020-12-23 19:53:13 +01:00
|
|
|
|
|
|
|
MANAGERS = ADMINS
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
|
|
'NAME': '__APP__',
|
|
|
|
'USER': '__APP__',
|
|
|
|
'PASSWORD': '__DB_PWD__',
|
|
|
|
'HOST': '127.0.0.1',
|
|
|
|
'PORT': '5432', # Default Postgres Port
|
|
|
|
'CONN_MAX_AGE': 600,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Title of site to use
|
|
|
|
SITE_TITLE = '__APP__'
|
|
|
|
|
|
|
|
# Site domain
|
|
|
|
SITE_DOMAIN = '__DOMAIN__'
|
|
|
|
|
|
|
|
# Subject of emails includes site title
|
|
|
|
EMAIL_SUBJECT_PREFIX = f'[{SITE_TITLE}] '
|
|
|
|
|
|
|
|
|
|
|
|
# E-mail address that error messages come from.
|
|
|
|
SERVER_EMAIL = 'noreply@__DOMAIN__'
|
|
|
|
|
|
|
|
# Default email address to use for various automated correspondence from
|
|
|
|
# the site managers. Used for registration emails.
|
|
|
|
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
|
|
|
|
|
|
# List of URLs your site is supposed to serve
|
|
|
|
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
|
|
|
2020-12-28 12:35:36 +01:00
|
|
|
|
2020-12-23 19:53:13 +01:00
|
|
|
# _____________________________________________________________________________
|
|
|
|
# Configuration for caching
|
|
|
|
CACHES = {
|
|
|
|
'default': {
|
|
|
|
'BACKEND': 'django_redis.cache.RedisCache',
|
|
|
|
'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__',
|
|
|
|
# If redis is running on same host as django_ynh, you might
|
|
|
|
# want to use unix sockets instead:
|
|
|
|
# 'LOCATION': 'unix:///var/run/redis/redis.sock?db=1',
|
|
|
|
'OPTIONS': {
|
|
|
|
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
|
|
|
},
|
|
|
|
'KEY_PREFIX': '__APP__',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-12-28 12:35:36 +01:00
|
|
|
|
2020-12-23 19:53:13 +01:00
|
|
|
# _____________________________________________________________________________
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
|
|
|
|
if PATH_URL:
|
|
|
|
STATIC_URL = f'/{PATH_URL}/static/'
|
|
|
|
MEDIA_URL = f'/{PATH_URL}/media/'
|
|
|
|
else:
|
|
|
|
# Installed to domain root, without a path prefix?
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
MEDIA_URL = '/media/'
|
|
|
|
|
|
|
|
STATIC_ROOT = str(FINAL_WWW_PATH / 'static')
|
|
|
|
MEDIA_ROOT = str(FINAL_WWW_PATH / 'media')
|
|
|
|
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
2020-12-28 12:35:36 +01:00
|
|
|
|
2020-12-23 19:53:13 +01:00
|
|
|
LOGGING = {
|
|
|
|
'version': 1,
|
|
|
|
'disable_existing_loggers': True,
|
|
|
|
'formatters': {
|
|
|
|
'verbose': {
|
|
|
|
'format': '{asctime} {levelname} {name} {module}.{funcName} {message}',
|
|
|
|
'style': '{',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers': {
|
|
|
|
'mail_admins': {
|
|
|
|
'level': 'ERROR',
|
|
|
|
'formatter': 'verbose',
|
|
|
|
'class': 'django.utils.log.AdminEmailHandler',
|
|
|
|
'include_html': True,
|
|
|
|
},
|
|
|
|
'log_file': {
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'class': 'logging.handlers.WatchedFileHandler',
|
|
|
|
'formatter': 'verbose',
|
|
|
|
'filename': str(LOG_FILE),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers': {
|
|
|
|
'': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
|
|
|
'django': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
|
|
|
'axes': {'handlers': ['log_file', 'mail_admins'], 'level': 'WARNING', 'propagate': False},
|
|
|
|
'django_tools': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
2020-12-28 12:35:36 +01:00
|
|
|
'django_ynh': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
2020-12-23 19:53:13 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
try:
|
|
|
|
from local_settings import * # noqa
|
|
|
|
except ImportError:
|
|
|
|
pass
|