2020-12-07 16:20:37 +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.
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
2020-12-08 09:31:10 +01:00
|
|
|
|
2020-12-07 16:20:37 +01:00
|
|
|
from pathlib import Path as __Path
|
|
|
|
|
2021-09-15 20:39:29 +02:00
|
|
|
from django_yunohost_integration.base_settings import * # noqa
|
|
|
|
from django_yunohost_integration.secret_key import get_or_create_secret as __get_or_create_secret
|
2020-12-07 16:20:37 +01:00
|
|
|
from inventory_project.settings.base import * # noqa
|
|
|
|
|
2020-12-29 13:58:40 +01:00
|
|
|
|
|
|
|
DEBUG = False # Don't turn DEBUG on in production!
|
2020-12-07 16:20:37 +01:00
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
2020-12-09 13:31:25 +01:00
|
|
|
FINAL_HOME_PATH = __Path('__FINAL_HOME_PATH__') # /opt/yunohost/$app
|
2020-12-08 09:31:10 +01:00
|
|
|
assert FINAL_HOME_PATH.is_dir(), f'Directory not exists: {FINAL_HOME_PATH}'
|
|
|
|
|
2020-12-09 13:31:25 +01:00
|
|
|
FINAL_WWW_PATH = __Path('__FINAL_WWW_PATH__') # /var/www/$app
|
2020-12-08 09:31:10 +01:00
|
|
|
assert FINAL_WWW_PATH.is_dir(), f'Directory not exists: {FINAL_WWW_PATH}'
|
|
|
|
|
2020-12-09 19:05:47 +01:00
|
|
|
LOG_FILE = __Path('__LOG_FILE__') # /var/log/$app/pyinventory.log
|
2020-12-08 09:31:10 +01:00
|
|
|
assert LOG_FILE.is_file(), f'File not exists: {LOG_FILE}'
|
2020-12-07 16:20:37 +01:00
|
|
|
|
2020-12-09 13:31:25 +01:00
|
|
|
PATH_URL = '__PATH_URL__' # $YNH_APP_ARG_PATH
|
|
|
|
PATH_URL = PATH_URL.strip('/')
|
|
|
|
|
2020-12-07 16:20:37 +01:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
2020-12-29 13:58:40 +01:00
|
|
|
ROOT_URLCONF = 'urls' # /opt/yunohost/pyinventory/ynh_urls.py
|
2020-12-09 12:05:24 +01:00
|
|
|
|
2020-12-29 13:58:40 +01:00
|
|
|
# Function that will be called to finalize a user profile:
|
|
|
|
YNH_SETUP_USER = 'setup_user.setup_project_user'
|
|
|
|
|
|
|
|
SECRET_KEY = __get_or_create_secret(FINAL_HOME_PATH / 'secret.txt') # /opt/yunohost/$app/secret.txt
|
|
|
|
|
2021-09-15 20:39:29 +02:00
|
|
|
INSTALLED_APPS.append('django_yunohost_integration')
|
2020-12-29 13:58:40 +01:00
|
|
|
|
|
|
|
MIDDLEWARE.insert(
|
|
|
|
MIDDLEWARE.index('django.contrib.auth.middleware.AuthenticationMiddleware') + 1,
|
|
|
|
# login a user via HTTP_REMOTE_USER header from SSOwat:
|
2021-09-15 20:39:29 +02:00
|
|
|
'django_yunohost_integration.sso_auth.auth_middleware.SSOwatRemoteUserMiddleware',
|
2020-12-29 13:58:40 +01:00
|
|
|
)
|
2020-12-12 12:23:07 +01:00
|
|
|
|
2020-12-20 19:42:08 +01:00
|
|
|
# Keep ModelBackend around for per-user permissions and superuser
|
|
|
|
AUTHENTICATION_BACKENDS = (
|
|
|
|
'axes.backends.AxesBackend', # AxesBackend should be the first backend!
|
2020-12-29 13:58:40 +01:00
|
|
|
#
|
2020-12-20 19:42:08 +01:00
|
|
|
# Authenticate via SSO and nginx 'HTTP_REMOTE_USER' header:
|
2021-09-15 20:39:29 +02:00
|
|
|
'django_yunohost_integration.sso_auth.auth_backend.SSOwatUserBackend',
|
2020-12-29 13:58:40 +01:00
|
|
|
#
|
2020-12-20 19:42:08 +01:00
|
|
|
# Fallback to normal Django model backend:
|
|
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
|
|
)
|
2020-12-29 13:58:40 +01:00
|
|
|
|
2020-12-20 19:42:08 +01:00
|
|
|
LOGIN_REDIRECT_URL = None
|
|
|
|
LOGIN_URL = '/yunohost/sso/'
|
|
|
|
LOGOUT_REDIRECT_URL = '/yunohost/sso/'
|
|
|
|
# /yunohost/sso/?action=logout
|
2020-12-12 12:23:07 +01:00
|
|
|
|
2020-12-20 19:42:08 +01:00
|
|
|
# -----------------------------------------------------------------------------
|
2020-12-12 12:23:07 +01:00
|
|
|
|
|
|
|
|
2020-12-29 13:58:40 +01:00
|
|
|
ADMINS = (('__ADMIN__', '__ADMINMAIL__'),)
|
2020-12-07 16:20:37 +01:00
|
|
|
|
|
|
|
MANAGERS = ADMINS
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.postgresql',
|
2022-09-13 21:08:58 +02:00
|
|
|
'NAME': '__DB_NAME__',
|
|
|
|
'USER': '__DB_USER__',
|
2020-12-07 16:20:37 +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.
|
|
|
|
DEFAULT_FROM_EMAIL = '__ADMINMAIL__'
|
|
|
|
|
|
|
|
# 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__',
|
|
|
|
# If redis is running on same host as PyInventory, 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__',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# _____________________________________________________________________________
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
|
2020-12-09 13:31:25 +01:00
|
|
|
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/'
|
2020-12-07 16:20:37 +01:00
|
|
|
|
2020-12-09 13:31:25 +01:00
|
|
|
STATIC_ROOT = str(FINAL_WWW_PATH / 'static')
|
2020-12-08 09:31:10 +01:00
|
|
|
MEDIA_ROOT = str(FINAL_WWW_PATH / 'media')
|
2020-12-07 16:20:37 +01:00
|
|
|
|
2020-12-19 19:29:58 +01:00
|
|
|
# _____________________________________________________________________________
|
|
|
|
# django-ckeditor
|
|
|
|
|
|
|
|
CKEDITOR_BASEPATH = STATIC_URL + 'ckeditor/ckeditor/'
|
2020-12-09 13:31:25 +01:00
|
|
|
|
2020-12-19 20:16:49 +01:00
|
|
|
# _____________________________________________________________________________
|
|
|
|
# Django-dbbackup
|
|
|
|
|
2020-12-20 19:42:08 +01:00
|
|
|
DBBACKUP_STORAGE_OPTIONS['location'] = str(FINAL_HOME_PATH / 'backups')
|
2020-12-19 20:16:49 +01:00
|
|
|
|
2020-12-07 16:20:37 +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,
|
|
|
|
},
|
2020-12-20 19:42:08 +01:00
|
|
|
'log_file': {
|
2020-12-07 16:20:37 +01:00
|
|
|
'level': 'DEBUG',
|
2020-12-08 09:31:10 +01:00
|
|
|
'class': 'logging.handlers.WatchedFileHandler',
|
2020-12-07 16:20:37 +01:00
|
|
|
'formatter': 'verbose',
|
2020-12-08 09:31:10 +01:00
|
|
|
'filename': str(LOG_FILE),
|
2020-12-07 16:20:37 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers': {
|
2020-12-20 19:42:08 +01:00
|
|
|
'': {'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},
|
2022-01-08 18:26:36 +01:00
|
|
|
'django_yunohost_integration': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
2020-12-20 19:42:08 +01:00
|
|
|
'inventory': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
2020-12-07 16:20:37 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
try:
|
2020-12-19 20:06:07 +01:00
|
|
|
from local_settings import * # noqa
|
2020-12-07 16:20:37 +01:00
|
|
|
except ImportError:
|
|
|
|
pass
|