221 lines
6.0 KiB
Python
221 lines
6.0 KiB
Python
# Setting the path
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent
|
|
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
# Load environment variables from .env file if python-dotenv is installed
|
|
try:
|
|
from dotenv import load_dotenv
|
|
load_dotenv(os.path.join(PROJECT_PATH, ".env"))
|
|
except ImportError:
|
|
pass
|
|
|
|
|
|
# Django settings for blechreiz project.
|
|
|
|
# Set DJANGO_DEBUG=True in .env for local development; leave unset (or False) in production.
|
|
DEBUG = os.environ.get("DJANGO_DEBUG", "False") == "True"
|
|
|
|
ADMINS = [
|
|
("Martin Bauer", "bauer_martin@gmx.de"),
|
|
]
|
|
|
|
MANAGERS = ADMINS
|
|
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.sqlite3",
|
|
"NAME": os.path.join(PROJECT_PATH, "database.sqlite"),
|
|
}
|
|
}
|
|
|
|
# Default primary key field type
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
# Email
|
|
|
|
EMAIL_HOST = "smtp.blechreiz.com"
|
|
EMAIL_HOST_USER = "m02b721a"
|
|
EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD", "")
|
|
EMAIL_USE_TLS = False
|
|
|
|
|
|
# Hosts/domain names that are valid for this site; required if DEBUG is False
|
|
ALLOWED_HOSTS = ["localhost", "127.0.0.1", ".blechreiz.com", ".bauer.tech"]
|
|
|
|
CSRF_TRUSTED_ORIGINS = ["https://br.bauer.tech", "https://*.bauer.tech", "https://*.blechreiz.com"]
|
|
|
|
# Local time zone for this installation.
|
|
TIME_ZONE = "Europe/Berlin"
|
|
|
|
# Language code for this installation.
|
|
LANGUAGE_CODE = "de"
|
|
|
|
SITE_ID = 1
|
|
|
|
# Internationalization
|
|
USE_I18N = True
|
|
USE_L10N = True
|
|
USE_TZ = True
|
|
|
|
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
|
MEDIA_ROOT = PROJECT_PATH + "/media/"
|
|
|
|
# URL that handles the media served from MEDIA_ROOT.
|
|
MEDIA_URL = "/media/"
|
|
|
|
# Absolute path to the directory static files should be collected to.
|
|
STATIC_ROOT = PROJECT_PATH + "/static_collection"
|
|
|
|
# URL prefix for static files.
|
|
STATIC_URL = "/static/"
|
|
|
|
LOGIN_URL = "/musicians/login"
|
|
PUBLIC_URLS = (
|
|
"^musicians/login/?$",
|
|
"^musicians/login/usernames/?$",
|
|
"^eventplanner_gcal/gcalApiCallback*",
|
|
# Static and media files must be accessible without login
|
|
r"^static/",
|
|
r"^media/",
|
|
)
|
|
|
|
# Additional locations of static files
|
|
STATICFILES_DIRS = [
|
|
PROJECT_PATH + "/static",
|
|
]
|
|
|
|
# List of finder classes that know how to find static files in various locations.
|
|
STATICFILES_FINDERS = [
|
|
"django.contrib.staticfiles.finders.FileSystemFinder",
|
|
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
|
]
|
|
|
|
# Make this unique, and don't share it with anybody.
|
|
SECRET_KEY = os.environ["DJANGO_SECRET_KEY"]
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
# WhiteNoise serves static files directly — must be right after SecurityMiddleware
|
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
|
"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",
|
|
"blechreiz.middleware.EnforceLoginMiddleware",
|
|
"blechreiz.middleware.DetectDevice",
|
|
]
|
|
|
|
ROOT_URLCONF = "blechreiz.urls"
|
|
|
|
# Python dotted path to the WSGI application used by Django's runserver.
|
|
WSGI_APPLICATION = "blechreiz.wsgi.application"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [
|
|
PROJECT_PATH + "/templates",
|
|
],
|
|
"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",
|
|
"django.template.context_processors.i18n",
|
|
"django.template.context_processors.media",
|
|
"django.template.context_processors.static",
|
|
"sekizai.context_processors.sekizai",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.sites",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
# Third-party apps
|
|
"crispy_forms",
|
|
"crispy_bootstrap5",
|
|
"sekizai",
|
|
"rest_framework",
|
|
# Own apps
|
|
"bootstrapTheme",
|
|
"website",
|
|
"musicians",
|
|
"eventplanner",
|
|
"eventplanner_gcal",
|
|
# "simpleforum", # Disabled
|
|
"location_field",
|
|
"scoremanager",
|
|
# 'imagestore', # Disabled
|
|
]
|
|
|
|
IMAGESTORE_TEMPLATE = "website/base.html"
|
|
|
|
|
|
REST_FRAMEWORK = {
|
|
"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated"],
|
|
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
|
|
"PAGE_SIZE": 10,
|
|
}
|
|
|
|
|
|
GCAL_COUPLING = {
|
|
"eventPrefix": "Blechreiz: ",
|
|
"developerKey": "blechreiz-homepage",
|
|
"clientId": "34462582242-4kpdvvbi27ajt4u22uitqurpve9o8ipj.apps.googleusercontent.com",
|
|
"client_secret": os.environ.get("GCAL_CLIENT_SECRET", ""),
|
|
"credentials_file": PROJECT_PATH + "/calendarCredentials.dat",
|
|
"push_url": "https://br.bauer.tech/eventplanner_gcal/gcalApiCallback",
|
|
}
|
|
|
|
|
|
# Crispy Forms configuration
|
|
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
|
|
CRISPY_TEMPLATE_PACK = "bootstrap5"
|
|
|
|
|
|
# Logging configuration
|
|
LOGGING = {
|
|
"version": 1,
|
|
"disable_existing_loggers": False,
|
|
"handlers": {
|
|
"file": {
|
|
"level": "DEBUG",
|
|
"class": "logging.FileHandler",
|
|
"filename": PROJECT_PATH + "/eventplanner.log",
|
|
},
|
|
"console": {
|
|
"level": "DEBUG",
|
|
"class": "logging.StreamHandler",
|
|
},
|
|
},
|
|
"loggers": {
|
|
"eventplanner_gcal": {
|
|
"handlers": ["file", "console"],
|
|
"level": "DEBUG",
|
|
"propagate": True,
|
|
},
|
|
"eventplanner": {
|
|
"handlers": ["file", "console"],
|
|
"level": "DEBUG",
|
|
"propagate": True,
|
|
},
|
|
},
|
|
}
|