123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- """
- Django settings for this project.
-
- Generated by 'django-admin startproject' using Django 3.0.3.
-
- For more information on this file, see
- https://docs.djangoproject.com/en/3.0/topics/settings/
-
- For the full list of settings and their values, see
- https://docs.djangoproject.com/en/3.0/ref/settings/
- """
-
- import config
- from logging.handlers import SocketHandler as _SocketHandler
- import os
- import stat
- import sys
- import random
-
- try:
- from config import APP_NAME as ROOT_LOGGER_NAME
- except ImportError:
- ROOT_LOGGER_NAME = 'root'
-
-
- # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
- #
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-
- # Check permission of config.py
- #
- if sys.platform == 'linux' or sys.platform == 'linux2':
- st = os.stat(os.path.join(BASE_DIR, 'config.py'))
- if st.st_mode & stat.S_IRGRP or st.st_mode & stat.S_IROTH:
- raise PermissionError("conig.py is readable by group or others.")
-
- # Default values, if not defined in config.py
- #
- USER_CONFIG_DEFAULTS = {
- 'DEBUG': False,
- 'SECRET_KEY': None,
- 'DEFAULT_THEME': 'clear-green',
- 'ALLOWED_HOSTS': ['127.0.0.1', ],
- 'CSRF_TRUSTED_ORIGINS': [],
- }
-
- # Set configuration parameters
- #
- thismodule = sys.modules[__name__]
- for property_name in USER_CONFIG_DEFAULTS:
- try:
- value = getattr(config, property_name)
- except AttributeError:
- value = USER_CONFIG_DEFAULTS[property_name]
- setattr(thismodule, property_name, value)
-
- # Quick-start development settings - unsuitable for production
- # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
-
- # SECURITY WARNING: keep the secret key used in production secret!
- #
- if SECRET_KEY is None:
- chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
- s_key = ''.join([random.choice(chars) for n in range(50)])
- secret_key_warning = "You need to create a config.py file including at least a SECRET_KEY definition (e.g.: --> %s <--)." % repr(s_key)
- raise KeyError(secret_key_warning)
-
-
- # Application definition
- #
- INSTALLED_APPS = [
- 'patt.apps.PattConfig',
- 'themes.apps.ThemesConfig',
- 'users.apps.UsersConfig',
- 'mycreole.apps.MycreoleConfig',
- #
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'simple_history',
- ]
-
- MIDDLEWARE = [
- 'django.middleware.security.SecurityMiddleware',
- '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',
- 'simple_history.middleware.HistoryRequestMiddleware',
- 'users.middleware.SettingsMiddleware',
- ]
-
- ROOT_URLCONF = 'main.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 = 'main.wsgi.application'
-
-
- # Database
- # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
- #
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
- }
- }
-
-
- # Password validation
- # https://docs.djangoproject.com/en/3.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',
- },
- ]
-
-
- # Search Engine
- #
- WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
-
-
- # Internationalization
- # https://docs.djangoproject.com/en/3.0/topics/i18n/
- #
- LANGUAGE_CODE = 'en-us'
- LANGUAGES = [
- ('en', 'English'),
- ('de', 'Deutsch'),
- ]
-
- TIME_ZONE = 'UTC'
-
- USE_I18N = True
- LOCALE_PATHS = [
- os.path.join(BASE_DIR, 'themes', 'locale'),
- os.path.join(BASE_DIR, 'users', 'locale'),
- os.path.join(BASE_DIR, 'patt', 'locale'),
- ]
-
- USE_L10N = True
-
- USE_TZ = True
-
-
- # Static files (CSS, JavaScript, Images)
- # https://docs.djangoproject.com/en/3.0/howto/static-files/
- #
- STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
- STATIC_URL = '/static/'
-
- MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
- MEDIA_URL = '/media/'
-
- MYCREOLE_ROOT = os.path.join(BASE_DIR, 'data', 'mycreole')
- MYCREOLE_ATTACHMENT_ACCESS = {
- 'read': 'patt.access.read_attachment',
- 'modify': 'patt.access.modify_attachment',
- }
- MYCREOLE_EXT_FILTERS = [
- 'patt.creole.task_link_filter',
- 'patt.creole.tasklist_link_filter',
- ]
-
- # Session parameters
- #
- PERSISTENT_SESSION_VARIABLES = []
-
-
- # Logging Configuration
- #
- class DjangoSocketHandler(_SocketHandler):
- def emit(self, record):
- if hasattr(record, 'request'):
- record.request = None
- return super().emit(record)
-
-
- default_handler = ['socket'] if DEBUG else ['console']
- #
- LOGGING = {
- 'version': 1,
- 'disable_existing_loggers': False,
- 'formatters': {
- 'short': {
- 'format': "%(asctime)s \"%(name)s - %(levelname)s - %(message)s\"",
- 'datefmt': '[%d/%b/%Y %H:%M:%S]',
- },
- 'long': {
- 'format': """~~~~(%(levelname)-10s)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- File "%(pathname)s", line %(lineno)d, in %(funcName)s
- %(asctime)s: %(name)s - %(message)s
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""",
- },
- },
- 'handlers': {
- 'console': {
- 'level': 'DEBUG',
- 'class': 'logging.StreamHandler',
- 'formatter': 'short',
- },
- 'socket': {
- 'level': 'DEBUG',
- 'class': 'main.settings.DjangoSocketHandler',
- 'host': '127.0.0.1',
- 'port': 19996,
- },
- },
- 'loggers': {
- 'django': {
- 'handlers': default_handler,
- 'level': 'INFO',
- 'propagate': False,
- },
- ROOT_LOGGER_NAME: {
- 'handlers': default_handler,
- 'level': 'DEBUG' if DEBUG else 'INFO',
- 'propagate': False,
- },
- },
- }
-
-
- # Other Configuration issues
- #
- LOGIN_URL = 'users-login'
-
- # Default Auto Filed
- #
- DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|