341 lignes
12 KiB
Python
341 lignes
12 KiB
Python
"""
|
|
Django settings for PIAF 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
|
|
import os
|
|
|
|
import environ
|
|
from django.contrib.messages import constants as messages
|
|
from collections import OrderedDict
|
|
|
|
|
|
# FIXME: Use a copy of the environment variables
|
|
# see: https://github.com/joke2k/django-environ/issues/58
|
|
environ.Env.ENVIRON = os.environ.copy()
|
|
|
|
# ENVIRONMENT VARIABLES AND PATHS
|
|
# ------------------------------------------------------------------------------
|
|
# Load environment variables
|
|
env = environ.Env()
|
|
|
|
# Package - e.g. Django project - root and apps directories
|
|
root_dir = environ.Path(__file__) - 2
|
|
apps_dir = root_dir.path('apps')
|
|
|
|
# Base directory of the app instance
|
|
# Note that it should be defined in OS environment variables in case of a
|
|
# multi-instances application.
|
|
base_dir = env.path('BASE_DIR', default=str(root_dir - 1))
|
|
|
|
# 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)
|
|
|
|
# Whether config.env should be loaded here
|
|
READ_CONFIG_FILE = env.bool('DJANGO_READ_CONFIG_FILE', default=True)
|
|
if READ_CONFIG_FILE:
|
|
# OS environment variables take precedence over variables from config.env
|
|
env.read_env(str(base_dir.path('config.env')))
|
|
|
|
# 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')),
|
|
)
|
|
}
|
|
|
|
# URLS
|
|
# ------------------------------------------------------------------------------
|
|
# https://docs.djangoproject.com/en/stable/ref/settings/#root-urlconf
|
|
ROOT_URLCONF = 'piaf.urls'
|
|
# https://docs.djangoproject.com/en/stable/ref/settings/#wsgi-application
|
|
WSGI_APPLICATION = 'piaf.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 = [
|
|
'constance',
|
|
'constance.backends.database',
|
|
]
|
|
|
|
# Project applications
|
|
LOCAL_APPS = [
|
|
'piaf.base',
|
|
]
|
|
|
|
# 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')
|
|
|
|
# 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': [
|
|
'constance.context_processors.config',
|
|
'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 = [
|
|
("""Cliss XXI""", 'tech@cliss21.com'),
|
|
]
|
|
|
|
# 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
|
|
|
|
# MESSAGES
|
|
# ------------------------------------------------------------------------------
|
|
# https://docs.djangoproject.com/en/stable/ref/settings/#message-tags
|
|
MESSAGE_TAGS = {
|
|
messages.INFO: 'primary',
|
|
messages.WARNING: 'warning',
|
|
messages.ERROR: 'danger',
|
|
messages.SUCCESS: 'success',
|
|
}
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# APPLICATION AND 3RD PARTY LIBRARY SETTINGS
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
# TIPI CONFIGURATION
|
|
# ------------------------------------------------------------------------------
|
|
|
|
NUMERO_REGIE = env.str('NUMERO_REGIE', default='000001')
|
|
|
|
SAISIE_TIPI = env.str('SAISIE_TIPI', default='T')
|
|
|
|
TIPI_TRUSTED_NETWORK = env.str('TIPI_TRUSTED_NETWORK', default='127.0.0.1')
|
|
|
|
# RESTHYS CONNECTION
|
|
# ------------------------------------------------------------------------------
|
|
RESTHYS_BASEURL = env.str('RESTHYS_BASEURL', default='http://127.0.0.1:8080/')
|
|
|
|
RESTHYS_AUTHKEY = env.str('RESTHYS_AUTHKEY', default='')
|
|
|
|
# CONSTANCE CONFIGURATION
|
|
# ------------------------------------------------------------------------------
|
|
CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'
|
|
|
|
CONSTANCE_CONFIG = OrderedDict(
|
|
[
|
|
('SITE_OWNER_NAME', ('Cliss XXI', "Nom de l'exploitant")),
|
|
('SITE_OWNER_URL', ("//cliss21.org", "Lien vers l'exploitant")),
|
|
('SITE_WELCOME', ('Bienvenue', "Mot d'accueil")),
|
|
(
|
|
'SITE_DESCRIPTION',
|
|
(
|
|
'Inscrivez, réservez, payez vos activités périscolaires sur le '
|
|
'portail familial de Cliss 21',
|
|
"Description du site sur la page d'accueil",
|
|
),
|
|
),
|
|
('SITE_CONTACT_ADDRESS', ('contact@cliss21.com', "Adresse de contact")),
|
|
('SITE_CONTACT_NAME', ('le Pole Scolarité Jeunesse', "Nom du contact")),
|
|
(
|
|
'MENTIONS_LEGALES',
|
|
(
|
|
'''
|
|
Dénomination ou raison sociale de ;<br>
|
|
Adresse du siège social ;<br>
|
|
Numéro de téléphone ;<br>
|
|
Directeur de publication ; (si publication type presse)<br>
|
|
Capital social ;<br>
|
|
Numéro d’inscription au registre du commerce et des
|
|
sociétés (RCS) ou au répertoire des métiers ;<br>
|
|
''',
|
|
'Mentions légales',
|
|
),
|
|
)
|
|
]
|
|
)
|
|
|
|
CONSTANCE_CONFIG_FIELDSETS = {
|
|
'Options générales': (
|
|
'SITE_OWNER_NAME',
|
|
'SITE_OWNER_URL',
|
|
'SITE_WELCOME',
|
|
'SITE_DESCRIPTION',
|
|
'SITE_CONTACT_ADDRESS',
|
|
'SITE_CONTACT_NAME',
|
|
'MENTIONS_LEGALES',
|
|
)
|
|
}
|