import os from pathlib import Path from dotenv import load_dotenv from input.utils.settings import env, password_validators BASE_DIR = Path(__file__).parents[1] load_dotenv(BASE_DIR / '.env') DEBUG = env('DEBUG', False) SECRET_KEY = env('SECRET_KEY') ALLOWED_HOSTS = ['*'] HOST = env('HOST', 'http://localhost:8000') INSTALLED_APPS = [ 'input.apps.InputConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'formtools', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'foerderbarometer.urls' DJANGO_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', ], }, } TEMPLATES = [DJANGO_TEMPLATES] WSGI_APPLICATION = 'foerderbarometer.wsgi.application' DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' DATABASE_ENGINE = env('DATABASE_ENGINE', 'mysql') DATABASE_SQLITE = { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } DATABASE_MYSQL = { 'ENGINE': 'django.db.backends.mysql', 'NAME': env('DATABASE_NAME', 'fdb'), 'USER': env('DATABASE_USER', 'fdb'), 'PASSWORD': env('DATABASE_PASSWORD'), 'HOST': env('DATABASE_HOST', 'localhost'), 'PORT': env('DATABASE_PORT', 3306), 'OPTIONS': { 'charset' : 'utf8', 'use_unicode' : True, 'init_command': 'SET ' 'storage_engine=INNODB,' 'character_set_connection=utf8,' 'collation_connection=utf8_bin' }, 'TEST_CHARSET': 'utf8', 'TEST_COLLATION': 'utf8_general_ci', } if DATABASE_ENGINE == 'mysql': DATABASE_DEFAULT = DATABASE_MYSQL else: DATABASE_DEFAULT = DATABASE_SQLITE DATABASES = { 'default': DATABASE_DEFAULT, } EMAIL_BACKEND = env('EMAIL_BACKEND', 'console') if EMAIL_BACKEND == 'smtp': EMAIL_HOST = env('EMAIL_HOST', 'email.wikimedia.de') EMAIL_PORT = env('EMAIL_PORT', 587) EMAIL_USE_TLS = env('EMAIL_USE_TLS', True) EMAIL_HOST_USER = env('EMAIL_HOST_USER') EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD') EMAIL_BACKEND = f'django.core.mail.backends.{EMAIL_BACKEND}.EmailBackend' EMAIL_URL_PREFIX = env('EMAIL_URL_PREFIX', HOST) AUTH_PASSWORD_VALIDATORS = password_validators( 'UserAttributeSimilarityValidator', 'MinimumLengthValidator', 'CommonPasswordValidator', 'NumericPasswordValidator', ) USE_I18N = True USE_L10N = True LANGUAGE_CODE = env('LANGUAGE_CODE', 'en-us') USE_TZ = True TIME_ZONE = env('TIME_ZONE', 'UTC') STATIC_ROOT = BASE_DIR / 'staticfiles' STATIC_URL = '/static/' FORM_RENDERER = 'input.forms.TableFormRenderer' if OAUTH_ENABLED := env('OAUTH_ENABLED', not DEBUG): MIDDLEWARE += ['input.middleware.oauth.OAuthMiddleware'] OAUTH_CLIENT_NAME = env('OAUTH_CLIENT_NAME') OAUTH_CLIENT = { 'client_id': env('OAUTH_CLIENT_ID'), 'client_secret': env('OAUTH_CLIENT_SECRET'), 'access_token_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/access_token', 'authorize_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/authorize', 'api_base_url': 'https://meta.wikimedia.org/w/rest.php/oauth2/resource', 'redirect_uri': env('OAUTH_REDIRECT_URI', f'{HOST}/oauth/callback'), 'client_kwargs': { 'scope': 'basic', 'token_placement': 'header' }, 'userinfo_endpoint': 'resource/profile', } OAUTH_URL_WHITELISTS = ['/admin'] OAUTH_COOKIE_SESSION_ID = 'sso_session_id' IF_EMAIL = env('IF_EMAIL', 'community@wikimedia.de') SURVEY_EMAIL = env('SURVEY_EMAIL', 'sandro.halank@wikimedia.de') SURVEY_PREFIX = env('SURVEY_PREFIX', 'https://wikimedia.sslsurvey.de/Foerderbarometer/?') DATAPROTECTION = 'https://www.wikimedia.de/datenschutz/#datenerfassung' FOERDERRICHTLINIEN = 'https://de.wikipedia.org/wiki/Wikipedia:Wikimedia_Deutschland/Richtlinie_zur_Förderung_der_Communitys' NUTZUNGSBEDINGUNGEN = 'static/input/nutzungsbedingungen.html' NUTZUNGSBEDINGUNGEN_EMAIL_SERVICE = 'static/input/nutzungsbedingungen-mail.pdf' NUTZUNGSBEDINGUNGEN_MAILINGLISTEN = 'static/input/nutzungsbedingungen-mailinglisten.pdf' NUTZUNGSBEDINGUNGEN_LITERATURSTIPENDIUM = 'static/input/nutzungsbedingungen-literaturstipendium.pdf' NUTZUNGSBEDINGUNGEN_OTRS = 'static/input/2025_Nutzungsvereinbarung_OTRS.docx.pdf' NUTZUNGSBEDINGUNGEN_VISITENKARTEN = 'static/input/nutzungsbedingungen-visitenkarten.pdf'