2024-07-14 22:19:37 +00:00
|
|
|
"""Settings for the project."""
|
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
from pathlib import Path
|
2021-02-28 22:03:32 +00:00
|
|
|
|
2024-08-03 17:55:32 +00:00
|
|
|
import django_stubs_ext
|
2021-02-28 22:55:01 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2021-02-27 20:07:48 +00:00
|
|
|
from environs import Env
|
2018-06-23 11:00:26 +00:00
|
|
|
|
2024-08-03 17:55:32 +00:00
|
|
|
django_stubs_ext.monkeypatch()
|
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
env = Env()
|
|
|
|
env.read_env()
|
2018-06-23 11:00:26 +00:00
|
|
|
|
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
2021-02-28 22:55:01 +00:00
|
|
|
PROJECT_DIR = BASE_DIR / "project"
|
2018-06-23 11:00:26 +00:00
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
SECRET_KEY = env.str("SECRET_KEY", default="something-very-secret")
|
2018-06-23 11:00:26 +00:00
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
DEBUG = env.bool("DEBUG", default=False)
|
2018-06-23 11:00:26 +00:00
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=["*"])
|
2022-08-09 17:29:42 +00:00
|
|
|
CSRF_TRUSTED_ORIGINS = env.list(
|
2023-01-11 20:55:58 +00:00
|
|
|
"CSRF_TRUSTED_ORIGINS",
|
|
|
|
default=["http://localhost:8000"],
|
2022-08-09 17:29:42 +00:00
|
|
|
)
|
2018-06-23 11:00:26 +00:00
|
|
|
|
2021-03-03 16:46:19 +00:00
|
|
|
ADMINS = [tuple(x.split(":")) for x in env.list("DJANGO_ADMINS", default=[])]
|
2021-03-03 14:18:57 +00:00
|
|
|
|
2021-12-13 19:44:09 +00:00
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
2018-06-23 11:00:26 +00:00
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
2023-01-11 20:55:58 +00:00
|
|
|
DJANGO_APPS = [
|
2019-08-31 22:27:36 +00:00
|
|
|
"django.contrib.admin",
|
|
|
|
"django.contrib.auth",
|
|
|
|
"django.contrib.contenttypes",
|
|
|
|
"django.contrib.sessions",
|
|
|
|
"django.contrib.messages",
|
|
|
|
"django.contrib.staticfiles",
|
|
|
|
"django.contrib.sites",
|
2023-01-11 20:55:58 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
THIRD_PARTY_APPS = [
|
2021-02-27 20:07:48 +00:00
|
|
|
"allauth",
|
|
|
|
"allauth.account",
|
2024-01-14 11:27:36 +00:00
|
|
|
"django_view_decorator",
|
2023-01-11 20:55:58 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
LOCAL_APPS = [
|
2021-02-28 11:41:10 +00:00
|
|
|
"utils",
|
2019-08-31 22:27:36 +00:00
|
|
|
"accounting",
|
|
|
|
"membership",
|
2018-06-23 11:00:26 +00:00
|
|
|
]
|
|
|
|
|
2023-01-11 20:55:58 +00:00
|
|
|
INSTALLED_APPS = [
|
|
|
|
*DJANGO_APPS,
|
|
|
|
*THIRD_PARTY_APPS,
|
|
|
|
*LOCAL_APPS,
|
|
|
|
]
|
2022-08-09 14:33:56 +00:00
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
DATABASES = {"default": env.dj_db_url("DATABASE_URL")}
|
|
|
|
|
2018-06-23 11:00:26 +00:00
|
|
|
MIDDLEWARE = [
|
2019-08-31 22:27:36 +00:00
|
|
|
"django.middleware.security.SecurityMiddleware",
|
2021-03-01 19:34:51 +00:00
|
|
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
2019-08-31 22:27:36 +00:00
|
|
|
"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",
|
2023-09-18 18:58:30 +00:00
|
|
|
"allauth.account.middleware.AccountMiddleware",
|
2018-06-23 11:00:26 +00:00
|
|
|
]
|
|
|
|
|
2019-08-31 22:27:36 +00:00
|
|
|
ROOT_URLCONF = "project.urls"
|
2018-06-23 11:00:26 +00:00
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
2019-08-31 22:27:36 +00:00
|
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
2021-02-28 22:55:01 +00:00
|
|
|
"DIRS": [PROJECT_DIR / "templates"],
|
2019-08-31 22:27:36 +00:00
|
|
|
"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",
|
2023-01-11 20:55:58 +00:00
|
|
|
],
|
2023-10-02 19:19:25 +00:00
|
|
|
"builtins": [
|
|
|
|
"django.templatetags.i18n",
|
|
|
|
],
|
2018-06-23 11:00:26 +00:00
|
|
|
},
|
2023-01-11 20:55:58 +00:00
|
|
|
},
|
2018-06-23 11:00:26 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
AUTHENTICATION_BACKENDS = (
|
2019-08-31 22:27:36 +00:00
|
|
|
"django.contrib.auth.backends.ModelBackend",
|
|
|
|
"allauth.account.auth_backends.AuthenticationBackend",
|
2018-06-23 11:00:26 +00:00
|
|
|
)
|
|
|
|
|
2019-08-31 22:27:36 +00:00
|
|
|
WSGI_APPLICATION = "project.wsgi.application"
|
2018-06-23 11:00:26 +00:00
|
|
|
|
|
|
|
|
2021-12-13 19:44:09 +00:00
|
|
|
AUTH_PASSWORD_VALIDATORS = []
|
2018-06-23 11:00:26 +00:00
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
LANGUAGE_CODE = "da-dk"
|
2019-08-31 18:46:49 +00:00
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
TIME_ZONE = "Europe/Copenhagen"
|
2018-06-23 11:00:26 +00:00
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
2019-08-31 22:27:36 +00:00
|
|
|
STATIC_URL = "/static/"
|
2021-02-28 22:55:01 +00:00
|
|
|
STATICFILES_DIRS = [PROJECT_DIR / "static"]
|
2021-03-01 16:13:15 +00:00
|
|
|
STATIC_ROOT = BASE_DIR / "static"
|
2019-08-31 18:46:49 +00:00
|
|
|
|
2018-06-23 12:59:12 +00:00
|
|
|
SITE_ID = 1
|
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
LOGIN_REDIRECT_URL = "/"
|
|
|
|
|
2021-03-03 13:58:46 +00:00
|
|
|
EMAIL_BACKEND = env.str(
|
2023-01-11 20:55:58 +00:00
|
|
|
"EMAIL_BACKEND",
|
|
|
|
default="django.core.mail.backends.console.EmailBackend",
|
2021-03-03 13:58:46 +00:00
|
|
|
)
|
2021-03-03 17:06:36 +00:00
|
|
|
DEFAULT_FROM_EMAIL = env.str("DEFAULT_FROM_EMAIL", default="")
|
2024-08-03 18:53:18 +00:00
|
|
|
SERVER_EMAIL = env.str("SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
|
2021-03-03 13:58:46 +00:00
|
|
|
# Parse email URLs, e.g. "smtp://"
|
|
|
|
email = env.dj_email_url("EMAIL_URL", default="smtp://")
|
|
|
|
EMAIL_HOST = email["EMAIL_HOST"]
|
|
|
|
EMAIL_PORT = email["EMAIL_PORT"]
|
|
|
|
EMAIL_HOST_PASSWORD = email["EMAIL_HOST_PASSWORD"]
|
|
|
|
EMAIL_HOST_USER = email["EMAIL_HOST_USER"]
|
|
|
|
EMAIL_USE_TLS = email["EMAIL_USE_TLS"]
|
2018-06-23 19:08:56 +00:00
|
|
|
|
2021-02-27 20:07:48 +00:00
|
|
|
# Always show DDT in development for any IP, not just 127.0.0.1 or
|
|
|
|
# settings.INTERNAL_IPS. This is useful in a docker setup where the
|
|
|
|
# requesting IP isn't static.
|
|
|
|
DEBUG_TOOLBAR_CONFIG = {
|
|
|
|
"SHOW_TOOLBAR_CALLBACK": lambda _x: DEBUG,
|
|
|
|
}
|
|
|
|
|
2019-08-31 22:27:36 +00:00
|
|
|
CURRENCIES = ("DKK",)
|
|
|
|
CURRENCY_CHOICES = [("DKK", "DKK")]
|
2021-02-27 22:18:27 +00:00
|
|
|
|
2021-02-28 22:55:01 +00:00
|
|
|
LANGUAGES = [
|
|
|
|
("da", _("Danish")),
|
|
|
|
("en", _("English")),
|
|
|
|
]
|
|
|
|
|
|
|
|
# We store all translations in one location
|
|
|
|
LOCALE_PATHS = [PROJECT_DIR / "locale"]
|
2021-02-27 22:18:27 +00:00
|
|
|
|
|
|
|
# Allauth configuration
|
|
|
|
ACCOUNT_AUTHENTICATION_METHOD = "email"
|
|
|
|
ACCOUNT_EMAIL_REQUIRED = True
|
|
|
|
ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = False
|
2021-02-28 22:03:32 +00:00
|
|
|
ACCOUNT_USERNAME_REQUIRED = False
|
2022-08-09 14:33:56 +00:00
|
|
|
|
2024-02-09 21:04:30 +00:00
|
|
|
# Logging
|
|
|
|
# We want to log everything to stdout in docker
|
|
|
|
LOGGING = {
|
|
|
|
"version": 1,
|
|
|
|
"disable_existing_loggers": False,
|
|
|
|
"handlers": {
|
|
|
|
"console": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"class": "logging.StreamHandler",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"loggers": {
|
|
|
|
"": {
|
|
|
|
"handlers": ["console"],
|
|
|
|
"level": "DEBUG",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:55:32 +00:00
|
|
|
STRIPE_API_KEY = env.str("STRIPE_API_KEY")
|
|
|
|
STRIPE_ENDPOINT_SECRET = env.str("STRIPE_ENDPOINT_SECRET")
|
2024-02-09 21:04:30 +00:00
|
|
|
|
2022-08-09 14:33:56 +00:00
|
|
|
if DEBUG:
|
2023-01-11 20:55:58 +00:00
|
|
|
INSTALLED_APPS += ["debug_toolbar", "django_browser_reload"]
|
|
|
|
MIDDLEWARE += [
|
|
|
|
"debug_toolbar.middleware.DebugToolbarMiddleware",
|
|
|
|
"django_browser_reload.middleware.BrowserReloadMiddleware",
|
|
|
|
]
|
2022-08-09 14:33:56 +00:00
|
|
|
# Always show DDT in development for any IP, not just 127.0.0.1 or
|
|
|
|
# settings.INTERNAL_IPS. This is useful in a docker setup where the
|
|
|
|
# requesting IP isn't static.
|
|
|
|
DEBUG_TOOLBAR_CONFIG = {
|
|
|
|
"SHOW_TOOLBAR_CALLBACK": lambda _x: DEBUG,
|
|
|
|
}
|