Convertisseur Drupal 6 vers SPIP pour le site web libre à lire
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
drupal2spip_lal/drupal2spip_lal/settings/base.py

312 lines
10 KiB

"""
Django settings for drupal2spip_lal project.
For more information on this file, see
https://docs.djangoproject.com/en/stable/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/stable/ref/settings/
"""
import os.path
from email.utils import getaddresses
from . import base_dir, env, root_dir
# ENVIRONMENT VARIABLES AND PATHS
# ------------------------------------------------------------------------------
# Local directory used for static and templates overrides
local_dir = base_dir.path('local')
# Directory for variable stuffs, i.e. user-uploaded media
var_dir = base_dir.path('var')
if not os.path.isdir(var_dir()):
os.mkdir(var_dir(), mode=0o755)
# Location on which the application is served
APP_LOCATION = env('APP_LOCATION', default='/')
# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#debug
DEBUG = env.bool('DJANGO_DEBUG', default=True)
# Local time zone for this installation
TIME_ZONE = 'Europe/Paris'
# https://docs.djangoproject.com/en/stable/ref/settings/#language-code
LANGUAGE_CODE = 'fr'
# https://docs.djangoproject.com/en/dev/ref/settings/#site-id
SITE_ID = 1
# https://docs.djangoproject.com/en/stable/ref/settings/#use-i18n
USE_I18N = True
# https://docs.djangoproject.com/en/stable/ref/settings/#use-l10n
USE_L10N = True
# https://docs.djangoproject.com/en/stable/ref/settings/#use-tz
USE_TZ = True
# DATABASES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#databases
# https://django-environ.readthedocs.io/en/stable/#supported-types
DATABASES = {
'default': env.db(
'DJANGO_DATABASE_URL',
default='sqlite:///{}'.format(base_dir('sqlite.db')),
),
'drupal': env.db_url(
'DRUPAL_DATABASE_URL',
default='sqlite:///{}'.format(base_dir('drupal.db')),
),
'spip': env.db_url(
'SPIP_DATABASE_URL',
default='sqlite:///{}'.format(base_dir('spip.db')),
),
}
SPIP_TABLES_PREFIX = env('SPIP_TABLES_PREFIX', default='spip')
DATABASE_ROUTERS = ['drupal2spip_lal.base.routers.Drupal2SPIPRouter']
# URLS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#root-urlconf
ROOT_URLCONF = 'drupal2spip_lal.urls'
# https://docs.djangoproject.com/en/stable/ref/settings/#wsgi-application
WSGI_APPLICATION = 'drupal2spip_lal.wsgi.application'
# APP CONFIGURATION
# ------------------------------------------------------------------------------
DJANGO_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
# Project dependencies
THIRD_PARTY_APPS = []
# Project applications
LOCAL_APPS = [
'drupal2spip_lal.base',
'drupal2spip_lal.drupal',
'drupal2spip_lal.spip',
]
# https://docs.djangoproject.com/en/stable/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
# PASSWORDS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#password-hashers
PASSWORD_HASHERS = [
# https://docs.djangoproject.com/en/stable/topics/auth/passwords/#using-argon2-with-django
# 'django.contrib.auth.hashers.Argon2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
'django.contrib.auth.hashers.BCryptPasswordHasher',
]
# https://docs.djangoproject.com/en/stable/topics/auth/passwords/#password-validation
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'
)
},
]
# MIDDLEWARE
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#middleware
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',
]
# STATIC
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#static-files
STATIC_ROOT = var_dir('static')
# https://docs.djangoproject.com/en/stable/ref/settings/#static-url
STATIC_URL = os.path.join(APP_LOCATION, 'static/')
# https://docs.djangoproject.com/en/stable/ref/settings/#staticfiles-dirs
STATICFILES_DIRS = [root_dir('static')]
if os.path.isdir(local_dir('static')):
STATICFILES_DIRS.insert(0, local_dir('static'))
# https://docs.djangoproject.com/en/stable/ref/contrib/staticfiles/#staticfiles-finders
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
# MEDIA
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#media-root
MEDIA_ROOT = var_dir('media')
SPIP_LOGO_DIR = env('SPIP_LOGO_DIR', default=MEDIA_ROOT)
# https://docs.djangoproject.com/en/stable/ref/settings/#media-url
MEDIA_URL = os.path.join(APP_LOCATION, 'media/')
# https://docs.djangoproject.com/en/stable/ref/settings/#file-upload-directory-permissions
FILE_UPLOAD_DIRECTORY_PERMISSIONS = 0o755
# https://docs.djangoproject.com/en/stable/ref/settings/#file-upload-permissions
FILE_UPLOAD_PERMISSIONS = 0o644
# TEMPLATES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#templates
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [root_dir('templates')],
'OPTIONS': {
'debug': DEBUG,
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
],
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
},
}
]
if os.path.isdir(local_dir('templates')):
TEMPLATES[0]['DIRS'].insert(0, local_dir('templates'))
# FIXTURES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#fixture-dirs
FIXTURE_DIRS = [root_dir('fixtures')]
# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/topics/email/#email-backends
# https://django-environ.readthedocs.io/en/stable/#supported-types
vars().update(env.email_url('DJANGO_EMAIL_URL', default='smtp://localhost:25'))
DEFAULT_FROM_EMAIL = env('DEFAULT_FROM_EMAIL', default='webmaster@localhost')
# Use the same email address for error messages
SERVER_EMAIL = DEFAULT_FROM_EMAIL
# ADMIN
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#admins
ADMINS = getaddresses(
[env('ADMINS', default='François Poulain (April) <fpoulain@april.org>')]
)
# https://docs.djangoproject.com/en/stable/ref/settings/#managers
MANAGERS = ADMINS
# SESSIONS AND COOKIES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/ref/settings/#session-cookie-path
SESSION_COOKIE_PATH = APP_LOCATION
# https://docs.djangoproject.com/en/stable/ref/settings/#csrf-cookie-path
CSRF_COOKIE_PATH = APP_LOCATION
# LOGGING
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/stable/topics/logging/
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(asctime)s - %(levelname)s - %(module)s: %(message)s',
},
'colored': {
'()': 'colorlog.ColoredFormatter',
'format': (
'%(log_color)s%(asctime)s - '
'%(levelname)s - %(name)s: %(message)s'
),
'log_colors': {
'DEBUG': 'bold_cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'bold_red',
},
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'colored',
},
'file': {
'level': 'INFO',
'class': 'logging.handlers.TimedRotatingFileHandler',
'filename': var_dir('log/drupal2spip_lal.log'),
'formatter': 'verbose',
'when': 'midnight',
'interval': 1,
'backupCount': 30,
},
},
'loggers': {
'django': {
'level': 'WARNING',
'handlers': ['file', 'console'],
'propagate': True,
},
'drupal2spip_lal': {
'level': 'DEBUG',
'handlers': ['file', 'console'],
'propagate': True,
},
},
}
if not os.path.isdir(var_dir('log')):
os.mkdir(var_dir('log'), mode=0o750)
# ------------------------------------------------------------------------------
# APPLICATION AND 3RD PARTY LIBRARY SETTINGS
# ------------------------------------------------------------------------------
DRUPAL_FQDN = env('DRUPAL_FQDN', default='www.april.org')