2021-02-28 10:56:42 +01:00
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Please do not modify this file, it will be reset at the next update.
|
2022-08-14 14:44:17 +02:00
|
|
|
# You can edit the file __FINALPATH__/local_settings.py and add/modify the settings you need.
|
2021-02-28 10:56:42 +01:00
|
|
|
# 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.
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
|
2020-12-28 12:35:36 +01:00
|
|
|
from pathlib import Path as __Path
|
2020-12-23 19:53:13 +01:00
|
|
|
|
2022-08-15 09:17:30 +02:00
|
|
|
from django.core.validators import EmailValidator as __EmailValidator
|
|
|
|
|
2021-09-15 19:16:35 +02:00
|
|
|
from django_yunohost_integration.base_settings import * # noqa
|
2022-08-12 17:56:02 +02:00
|
|
|
from django_yunohost_integration.secret_key import get_or_create_secret as __get_or_create_secret
|
2020-12-23 19:53:13 +01:00
|
|
|
|
|
|
|
|
2022-08-14 17:13:32 +02:00
|
|
|
FINALPATH = __Path('__FINALPATH__') # /opt/yunohost/$app
|
2022-08-14 14:44:17 +02:00
|
|
|
assert FINALPATH.is_dir(), f'Directory not exists: {FINALPATH}'
|
2020-12-23 19:53:13 +01:00
|
|
|
|
2022-08-14 17:13:32 +02:00
|
|
|
PUBLIC_PATH = __Path('__PUBLIC_PATH__') # /var/www/$app
|
|
|
|
assert PUBLIC_PATH.is_dir(), f'Directory not exists: {PUBLIC_PATH}'
|
|
|
|
|
2021-02-28 10:56:42 +01:00
|
|
|
LOG_FILE = __Path('__LOG_FILE__') # /var/log/$app/django_example_ynh.log
|
2020-12-23 19:53:13 +01:00
|
|
|
assert LOG_FILE.is_file(), f'File not exists: {LOG_FILE}'
|
|
|
|
|
|
|
|
PATH_URL = '__PATH_URL__' # $YNH_APP_ARG_PATH
|
|
|
|
PATH_URL = PATH_URL.strip('/')
|
|
|
|
|
2022-08-15 09:01:53 +02:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# config_panel.toml settings:
|
|
|
|
|
|
|
|
DEBUG_ENABLED = '__DEBUG_ENABLED__'
|
|
|
|
LOG_LEVEL = '__LOG_LEVEL__'
|
2022-08-15 09:17:30 +02:00
|
|
|
ADMIN_EMAIL = '__ADMIN_EMAIL__'
|
2022-08-15 09:01:53 +02:00
|
|
|
# -----------------------------------------------------------------------------
|
2022-08-15 09:17:30 +02:00
|
|
|
# Use/convert/validate config_panel.toml settings:
|
2022-08-15 09:01:53 +02:00
|
|
|
|
|
|
|
DEBUG = bool(int(DEBUG_ENABLED))
|
|
|
|
assert LOG_LEVEL in (
|
|
|
|
'DEBUG',
|
|
|
|
'INFO',
|
|
|
|
'WARNING',
|
|
|
|
'ERROR',
|
|
|
|
'CRITICAL',
|
|
|
|
), f'Invalid LOG_LEVEL: {LOG_LEVEL!r}'
|
2022-08-15 09:17:30 +02:00
|
|
|
__EmailValidator(message='ADMIN_EMAIL from config panel is not valid!')(ADMIN_EMAIL)
|
2022-08-15 09:01:53 +02:00
|
|
|
|
2020-12-23 19:53:13 +01:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
2020-12-29 15:04:36 +01:00
|
|
|
# Function that will be called to finalize a user profile:
|
2021-02-28 10:56:42 +01:00
|
|
|
YNH_SETUP_USER = 'setup_user.setup_project_user'
|
2020-12-28 18:52:29 +01:00
|
|
|
|
2022-08-14 14:44:17 +02:00
|
|
|
SECRET_KEY = __get_or_create_secret(FINALPATH / 'secret.txt') # /opt/yunohost/$app/secret.txt
|
2020-12-23 19:53:13 +01:00
|
|
|
|
2021-09-15 19:16:35 +02:00
|
|
|
# INSTALLED_APPS.append('<insert-your-app-here>')
|
2021-02-28 10:56:42 +01:00
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2022-08-15 09:17:30 +02:00
|
|
|
ADMINS = (('__ADMIN__', ADMIN_EMAIL),)
|
2020-12-23 19:53:13 +01:00
|
|
|
|
|
|
|
MANAGERS = ADMINS
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.postgresql',
|
2022-04-02 20:12:05 +02:00
|
|
|
'NAME': '__DB_NAME__',
|
|
|
|
'USER': '__DB_USER__',
|
2020-12-23 19:53:13 +01:00
|
|
|
'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.
|
2022-08-15 09:17:30 +02:00
|
|
|
DEFAULT_FROM_EMAIL = ADMIN_EMAIL
|
2020-12-23 19:53:13 +01:00
|
|
|
|
|
|
|
# List of URLs your site is supposed to serve
|
|
|
|
ALLOWED_HOSTS = ['__DOMAIN__']
|
|
|
|
|
|
|
|
# _____________________________________________________________________________
|
|
|
|
# Configuration for caching
|
|
|
|
CACHES = {
|
|
|
|
'default': {
|
|
|
|
'BACKEND': 'django_redis.cache.RedisCache',
|
|
|
|
'LOCATION': 'redis://127.0.0.1:6379/__REDIS_DB__',
|
2021-02-28 10:56:42 +01:00
|
|
|
# If redis is running on same host as PyInventory, you might
|
2020-12-23 19:53:13 +01:00
|
|
|
# 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__',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# _____________________________________________________________________________
|
|
|
|
# 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/'
|
|
|
|
|
2022-08-14 17:13:32 +02:00
|
|
|
STATIC_ROOT = str(PUBLIC_PATH / 'static')
|
|
|
|
MEDIA_ROOT = str(PUBLIC_PATH / 'media')
|
2021-02-28 10:56:42 +01:00
|
|
|
|
2022-08-15 09:01:53 +02:00
|
|
|
|
2021-02-28 10:56:42 +01:00
|
|
|
# -----------------------------------------------------------------------------
|
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': {
|
2022-08-15 09:01:53 +02:00
|
|
|
'': {'handlers': ['log_file', 'mail_admins'], 'level': LOG_LEVEL, 'propagate': False},
|
|
|
|
'django': {'handlers': ['log_file', 'mail_admins'], 'level': LOG_LEVEL, 'propagate': False},
|
|
|
|
'axes': {'handlers': ['log_file', 'mail_admins'], 'level': LOG_LEVEL, 'propagate': False},
|
2022-08-12 17:56:02 +02:00
|
|
|
'django_tools': {
|
|
|
|
'handlers': ['log_file', 'mail_admins'],
|
2022-08-15 09:01:53 +02:00
|
|
|
'level': LOG_LEVEL,
|
2022-08-12 17:56:02 +02:00
|
|
|
'propagate': False,
|
|
|
|
},
|
|
|
|
'django_yunohost_integration': {
|
|
|
|
'handlers': ['log_file', 'mail_admins'],
|
2022-08-15 09:01:53 +02:00
|
|
|
'level': LOG_LEVEL,
|
2022-08-12 17:56:02 +02:00
|
|
|
'propagate': False,
|
|
|
|
},
|
2020-12-23 19:53:13 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
try:
|
|
|
|
from local_settings import * # noqa
|
|
|
|
except ImportError:
|
|
|
|
pass
|