143 lines
3.9 KiB
Python
143 lines
3.9 KiB
Python
"""
|
|
Django settings for community_backup project.
|
|
|
|
Generated by 'django-admin startproject' using Django 6.0.3.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/6.0/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/6.0/ref/settings/
|
|
"""
|
|
|
|
from pathlib import Path
|
|
from importlib import import_module
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
|
|
|
|
|
|
ALLOWED_HOSTS = [
|
|
"*",
|
|
]
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"webui",
|
|
"crispy_forms",
|
|
"crispy_bootstrap5",
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
]
|
|
|
|
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
|
|
|
|
CRISPY_TEMPLATE_PACK = "bootstrap5"
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"django.middleware.common.CommonMiddleware",
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "community_backup.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [],
|
|
"APP_DIRS": True,
|
|
"OPTIONS": {
|
|
"context_processors": [
|
|
"django.template.context_processors.request",
|
|
"django.contrib.auth.context_processors.auth",
|
|
"django.contrib.messages.context_processors.messages",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = "community_backup.wsgi.application"
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
|
},
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
|
},
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
|
},
|
|
{
|
|
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
|
},
|
|
]
|
|
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/6.0/topics/i18n/
|
|
|
|
LANGUAGE_CODE = "en-us"
|
|
|
|
TIME_ZONE = "UTC"
|
|
|
|
USE_I18N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
|
|
|
STATIC_URL = "static/"
|
|
|
|
TASKS = {"default": {"BACKEND": "django.tasks.backends.immediate.ImmediateBackend"}}
|
|
|
|
STATIC_ROOT = BASE_DIR.parent.parent / "static"
|
|
|
|
# Import settings from configuration.py
|
|
try:
|
|
config_module = "community_backup.configuration"
|
|
module = import_module(config_module)
|
|
|
|
assert module.SECRET_KEY, "The Django SECRET is required."
|
|
assert module.BACKUP_USER, "The BACKUP_USER setting is required."
|
|
assert module.BACKUP_REPO_HOST, "The BACKUP_REPO_HOST setting is required."
|
|
assert module.BACKUP_HOME_DIR, "The BACKUP_HOME_DIR setting is required."
|
|
assert module.BACKUP_BORG_DIR, "The BACKUP_BORG_DIR setting is required."
|
|
assert module.BACKUP_AUTHORIZED_KEYS, (
|
|
"The BACKUP_AUTHORIZED_KEYS setting is required."
|
|
)
|
|
|
|
except ModuleNotFoundError:
|
|
print(f"could not find configuration file {config_module}")
|
|
exit(1)
|
|
|
|
BACKUP_USER = module.BACKUP_USER
|
|
BACKUP_REPO_HOST = module.BACKUP_REPO_HOST
|
|
BACKUP_HOME_DIR = module.BACKUP_HOME_DIR
|
|
BACKUP_BORG_DIR = module.BACKUP_BORG_DIR
|
|
BACKUP_AUTHORIZED_KEYS = module.BACKUP_AUTHORIZED_KEYS
|
|
DATABASES = module.DATABASES
|
|
SECRET_KEY = module.SECRET_KEY
|
|
|
|
DEBUG = getattr(module, "DEBUG", False)
|