dashboard/dashboard/settings.py

217 lines
5.9 KiB
Python

"""
Django settings for dashboard project.
Generated by 'django-admin startproject' using Django 4.0.3.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
from pathlib import Path
# 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/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-44zt@)$td7_yh(01q^hrce%h(311n!djn%%#s1b7$cvfy!pf7y"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
"whitenoise.runserver_nostatic",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"accounts",
"dash",
"support",
"oauth2_provider",
"payments",
"billing",
"infrastructure",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"oauth2_provider.middleware.OAuth2TokenMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
ROOT_URLCONF = "dashboard.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 = "dashboard.wsgi.application"
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "db-doesn't-exist",
"USER": "postgres",
"PASSWORD": "password",
"HOST": "localhost",
"PORT": "5432",
}
}
# Password validation
# https://docs.djangoproject.com/en/4.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/4.0/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
# not yet implemented so disabling as it provides performance benefits
# ref: https://docs.djangoproject.com/en/4.0/topics/i18n/translation/
USE_I18N = False
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / "static"
STATICFILES_DIRS = [
BASE_DIR / "common-static",
]
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
### django-oauth-toolkit configuration
OAUTH2_PROVIDER = {
"OIDC_ENABLED": True,
"PKCE_REQUIRED": False,
"SCOPES": {
"openid": "OpenID Connect scope",
},
}
## django-payments configuration
PAYMENT_MODEL = "billing.Payment" # please don't change this value
PAYMENT_HOST = "http://localhost:8000"
PAYMENT_VARIANTS = {
"stripe": (
"payments.stripe.StripeProvider",
{
"secret_key": "",
"public_key": "",
},
)
}
### Dashbaord specific configuration options
HOSTEA = {
"SOURCE_CODE": "https://forgejo.gna.org/Hostea/dashboard",
"RESTRICT_NEW_INTEGRATION_INSTALLATION": True,
"INSTANCE_MAINTAINER_CONTACT": "contact@gna.example.org",
"ACCOUNTS": {
"MAX_VERIFICATION_TOLERANCE_PERIOD": 60 * 60 * 24, # in seconds
"SUDO_TTL": 60 * 5,
},
"META": {
"FORGEJO_INSTANCE": "http://localhost:3000", # meta Forgejo insatnce
"FORGEJO_ORG_NAME": "Hostea", # Organisation name on Hostea meta instance
# Repository dedicated for handling support
# ref: https://forgejo.gna.org/Hostea/july-mvp/issues/17
"SUPPORT_REPOSITORY": "support",
},
"INFRA": {
"HOSTEA_REPO": {
# where to clone the repository
"PATH": "/srv/hostea/dashboard/infrastructure",
# Git remote URI of the repository
"REMOTE": "git@localhost:Hostea/enough.git",
# SSH key that can push to the Git repository remote mentioned above
"SSH_KEY": "/srv/hostea/deploy",
},
"HOSTEA_DOMAIN": "vm.gna.org", # domain at which Hostea VMs will be spun up
},
}
# Please see EMAIL_* configuration options:
# https://docs.djangoproject.com/en/4.1/ref/settings/#email-host
EMAIL_HOST = "localhost"
EMAIL_USE_TLS = False
EMAIL_USE_SSL = False
EMAIL_PORT = 10025
EMAIL_HOST_USER = "admin"
EMAIL_HOST_PASSWORD = "password"
DEFAULT_FROM_EMAIL: "no-reply@gna.org"
try:
from dashboard.local_settings import *
print("Found local_settings")
except ModuleNotFoundError:
pass