269 lines
7.7 KiB
Python
269 lines
7.7 KiB
Python
"""
|
|
Django settings for dynamicweb2 project.
|
|
|
|
Generated by 'django-admin startproject' using Django 4.2.7.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/4.2/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/4.2/ref/settings/
|
|
"""
|
|
import dotenv
|
|
import os
|
|
|
|
from pathlib import Path
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
PROJECT_DIR = os.path.abspath(
|
|
os.path.join(os.path.dirname(__file__), ".."),
|
|
)
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = True
|
|
|
|
ALLOWED_HOSTS = []
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'django.contrib.sites',
|
|
'bootstrap3',
|
|
'guardian',
|
|
'hosting',
|
|
]
|
|
|
|
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 = 'dynamicweb2.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [
|
|
os.path.join(PROJECT_DIR, 'hosting/templates/'),
|
|
os.path.join(PROJECT_DIR, 'templates/analytics'),
|
|
os.path.join(PROJECT_DIR, 'templates/gdpr'),
|
|
],
|
|
'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.media", # Updated import
|
|
"django.template.context_processors.static", # Updated import
|
|
"django.template.context_processors.tz", # Updated import
|
|
"django.contrib.messages.context_processors.messages",
|
|
'hosting.context_processor.google_analytics',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
|
|
WSGI_APPLICATION = 'dynamicweb2.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': BASE_DIR / 'db.sqlite3',
|
|
}
|
|
}
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/4.2/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.2/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/4.2/howto/static-files/
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
|
|
|
|
STATICFILES_FINDERS = (
|
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
)
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
|
|
def env(env_name):
|
|
return os.environ.get(env_name)
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = env('SECRET_KEY')
|
|
|
|
dotenv.load_dotenv("{0}/.env".format(PROJECT_DIR))
|
|
|
|
# LDAP setup
|
|
LDAP_ADMIN_DN = env('LDAP_ADMIN_DN')
|
|
LDAP_ADMIN_PASSWORD = env('LDAP_ADMIN_PASSWORD')
|
|
AUTH_LDAP_SERVER = env('LDAPSERVER')
|
|
|
|
LDAP_CUSTOMER_DN = env('LDAP_CUSTOMER_DN')
|
|
LDAP_CUSTOMER_GROUP_ID = int(env('LDAP_CUSTOMER_GROUP_ID'))
|
|
LDAP_MAX_UID_FILE_PATH = os.environ.get('LDAP_MAX_UID_FILE_PATH',
|
|
os.path.join(os.path.abspath(os.path.dirname(__file__)), 'ldap_max_uid_file')
|
|
)
|
|
LDAP_DEFAULT_START_UID = int(env('LDAP_DEFAULT_START_UID'))
|
|
|
|
# Search union over OUsss
|
|
AUTH_LDAP_START_TLS = bool(os.environ.get('LDAP_USE_TLS', False))
|
|
|
|
ENTIRE_SEARCH_BASE = env("ENTIRE_SEARCH_BASE")
|
|
|
|
AUTH_LDAP_USER_ATTR_MAP = {
|
|
"first_name": "givenName",
|
|
"last_name": "sn",
|
|
"email": "mail"
|
|
}
|
|
|
|
STRIPE_API_PRIVATE_KEY = env('STRIPE_API_PRIVATE_KEY')
|
|
STRIPE_API_PUBLIC_KEY = env('STRIPE_API_PUBLIC_KEY')
|
|
STRIPE_API_PRIVATE_KEY_TEST = env('STRIPE_API_PRIVATE_KEY_TEST')
|
|
|
|
GUARDIAN_GET_INIT_ANONYMOUS_USER = 'hosting.models.get_anonymous_user_instance'
|
|
|
|
AUTH_USER_MODEL = 'hosting.CustomUser'
|
|
|
|
AUTHENTICATION_BACKENDS = (
|
|
'dynamicweb2.backend.UngleichLDAPBackend',
|
|
'guardian.backends.ObjectPermissionBackend',
|
|
)
|
|
|
|
# TODO: upgrade to the latest bootstrap
|
|
BOOTSTRAP3 = {
|
|
|
|
# The URL to the jQuery JavaScript file
|
|
'jquery_url': '%shosting/js/jquery-1.11.1.min.js' % STATIC_URL,
|
|
|
|
# The Bootstrap base URL
|
|
'base_url': '%shosting/bootstrap-3.3.4/' % STATIC_URL,
|
|
|
|
# The complete URL to the Bootstrap CSS file
|
|
# (None means derive it from base_url)
|
|
'css_url': None,
|
|
|
|
# The complete URL to the Bootstrap CSS file (None means no theme)
|
|
'theme_url': None,
|
|
|
|
# The complete URL to the Bootstrap JavaScript file
|
|
# (None means derive it from base_url)
|
|
'javascript_url': None,
|
|
|
|
# Put JavaScript in the HEAD section of the HTML document
|
|
# (only relevant if you use bootstrap3.html)
|
|
'javascript_in_head': False,
|
|
|
|
# Include jQuery with Bootstrap JavaScript
|
|
# (affects django-bootstrap3 template tags)
|
|
'include_jquery': False,
|
|
|
|
# Label class to use in horizontal forms
|
|
'horizontal_label_class': 'col-md-3',
|
|
|
|
# Field class to use in horizontal forms
|
|
'horizontal_field_class': 'col-md-9',
|
|
|
|
# Set HTML required attribute on required fields
|
|
'set_required': True,
|
|
|
|
# Set HTML disabled attribute on disabled fields
|
|
'set_disabled': False,
|
|
|
|
# Set placeholder attributes to label if no placeholder is provided
|
|
'set_placeholder': True,
|
|
|
|
# Class to indicate required (better to set this in your Django form)
|
|
'required_css_class': '',
|
|
|
|
# Class to indicate error (better to set this in your Django form)
|
|
'error_css_class': 'has-error',
|
|
|
|
# Class to indicate success, meaning the field has valid input
|
|
# (better to set this in your Django form)
|
|
'success_css_class': 'has-success',
|
|
|
|
# Renderers (only set these if you have studied the source and understand
|
|
# the inner workings)
|
|
'formset_renderers': {
|
|
'default': 'bootstrap3.renderers.FormsetRenderer',
|
|
},
|
|
'form_renderers': {
|
|
'default': 'bootstrap3.renderers.FormRenderer',
|
|
},
|
|
'field_renderers': {
|
|
'default': 'bootstrap3.renderers.FieldRenderer',
|
|
'inline': 'bootstrap3.renderers.InlineFieldRenderer',
|
|
},
|
|
}
|
|
|
|
# from django.contrib.sites.models import Site
|
|
#
|
|
# # Ensure the query matches an existing site ID or domain
|
|
# try:
|
|
# site = Site.objects.get(id=1) # Replace '1' with the correct site ID
|
|
# except Site.DoesNotExist:
|
|
# # Handle the case where the site doesn't exist
|
|
# pass
|
|
|