2017-09-10 14:53:02 +00:00
# -*- mode: python; coding: utf-8 -*-
2020-11-23 16:06:37 +00:00
# Re2o est un logiciel d'administration développé initiallement au Rézo Metz. Il
2017-01-15 23:01:18 +00:00
# se veut agnostique au réseau considéré, de manière à être installable en
# quelques clics.
#
# Copyright © 2017 Gabriel Détraz
2019-09-29 14:02:28 +00:00
# Copyright © 2017 Lara Kermarec
2017-01-15 23:01:18 +00:00
# Copyright © 2017 Augustin Lemesle
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2016-07-04 23:15:51 +00:00
"""
Django settings for re2o project .
Generated by ' django-admin startproject ' using Django 1.8 .13 .
For more information on this file , see
https : / / docs . djangoproject . com / en / 1.8 / topics / settings /
For the full list of settings and their values , see
https : / / docs . djangoproject . com / en / 1.8 / ref / settings /
"""
2017-09-10 23:29:24 +00:00
from __future__ import unicode_literals
2016-07-04 23:15:51 +00:00
import os
2021-02-10 10:06:09 +00:00
2020-06-07 15:17:01 +00:00
from . settings_default import *
2021-02-10 10:06:09 +00:00
2020-06-07 15:17:01 +00:00
try :
2020-06-07 16:05:59 +00:00
from . settings_local import *
2020-06-07 15:17:01 +00:00
except ImportError :
pass
2018-04-16 18:07:54 +00:00
from django . utils . translation import ugettext_lazy as _
2016-07-04 23:15:51 +00:00
2018-04-14 19:29:16 +00:00
# The root directory for the project
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
2016-07-04 23:15:51 +00:00
BASE_DIR = os . path . dirname ( os . path . dirname ( os . path . abspath ( __file__ ) ) )
2016-07-06 21:03:13 +00:00
# Auth definition
PASSWORD_HASHERS = (
2019-11-04 16:55:03 +00:00
" re2o.login.SSHAPasswordHasher " ,
" re2o.login.MD5PasswordHasher " ,
" re2o.login.CryptPasswordHasher " ,
" django.contrib.auth.hashers.PBKDF2PasswordHasher " ,
2016-07-06 21:03:13 +00:00
)
2019-11-04 16:55:03 +00:00
AUTH_USER_MODEL = " users.User " # The class to use for authentication
LOGIN_URL = " /login/ " # The URL for login page
LOGIN_REDIRECT_URL = " / " # The URL for redirecting after login
2016-07-06 21:03:13 +00:00
2016-07-04 23:15:51 +00:00
# Application definition
2020-12-28 21:29:59 +00:00
# dal_legacy_static only needed for Django < 2.0 (https://django-autocomplete-light.readthedocs.io/en/master/install.html#django-versions-earlier-than-2-0)
2021-02-10 10:06:09 +00:00
EARLY_EXTERNAL_CONTRIB_APPS = (
" dal " ,
" dal_select2 " ,
" dal_legacy_static " ,
) # Need to be added before django.contrib.admin (https://django-autocomplete-light.readthedocs.io/en/master/install.html#configuration)
2018-04-14 19:29:16 +00:00
DJANGO_CONTRIB_APPS = (
2019-11-04 16:55:03 +00:00
" django.contrib.admin " ,
" django.contrib.auth " ,
" django.contrib.contenttypes " ,
" django.contrib.sessions " ,
" django.contrib.messages " ,
" django.contrib.staticfiles " ,
" django.contrib.humanize " ,
2018-04-14 19:29:16 +00:00
)
2019-11-04 16:55:03 +00:00
EXTERNAL_CONTRIB_APPS = ( " bootstrap3 " , " rest_framework " , " reversion " )
2018-04-14 19:29:16 +00:00
LOCAL_APPS = (
2019-11-04 16:55:03 +00:00
" users " ,
" machines " ,
" cotisations " ,
" topologie " ,
" search " ,
" re2o " ,
" preferences " ,
" logs " ,
2018-04-14 19:29:16 +00:00
)
INSTALLED_APPS = (
2021-02-10 10:06:09 +00:00
EARLY_EXTERNAL_CONTRIB_APPS
+ DJANGO_CONTRIB_APPS
+ EXTERNAL_CONTRIB_APPS
+ LOCAL_APPS
+ OPTIONNAL_APPS
2018-04-14 19:29:16 +00:00
)
2021-02-09 12:01:42 +00:00
MIDDLEWARE = (
" django.middleware.security.SecurityMiddleware " ,
2019-11-04 16:55:03 +00:00
" 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 " ,
" reversion.middleware.RevisionMiddleware " ,
2016-07-04 23:15:51 +00:00
)
2018-08-10 15:43:10 +00:00
2019-11-04 16:55:03 +00:00
AUTHENTICATION_BACKENDS = [ " re2o.login.RecryptBackend " ]
2018-08-10 15:43:10 +00:00
2018-06-22 21:28:29 +00:00
# Include debug_toolbar middleware if activated
2019-11-04 16:55:03 +00:00
if " debug_toolbar " in INSTALLED_APPS :
2018-06-22 21:28:29 +00:00
# Include this middleware at the beggining
MIDDLEWARE_CLASSES = (
2019-11-04 16:55:03 +00:00
" debug_toolbar.middleware.DebugToolbarMiddleware " ,
2018-06-22 21:28:29 +00:00
) + MIDDLEWARE_CLASSES
# Change the default show_toolbar middleware
DEBUG_TOOLBAR_CONFIG = {
2019-11-04 16:55:03 +00:00
" SHOW_TOOLBAR_CALLBACK " : " re2o.middleware.show_debug_toolbar "
2018-06-22 21:28:29 +00:00
}
2016-07-04 23:15:51 +00:00
2018-04-14 19:29:16 +00:00
# The root url module to define the project URLs
2019-11-04 16:55:03 +00:00
ROOT_URLCONF = " re2o.urls "
2016-07-04 23:15:51 +00:00
2018-04-14 19:29:16 +00:00
# The templates configuration (see Django documentation)
2016-07-04 23:15:51 +00:00
TEMPLATES = [
{
2019-11-04 16:55:03 +00:00
" BACKEND " : " django.template.backends.django.DjangoTemplates " ,
" DIRS " : [
2018-04-14 19:29:16 +00:00
# Use only absolute paths with '/' delimiters even on Windows
2019-11-04 16:55:03 +00:00
os . path . join ( BASE_DIR , " templates " ) . replace ( " \\ " , " / " ) ,
os . path . join ( BASE_DIR , " media " , " templates " ) . replace ( " \\ " , " / " ) ,
2018-04-14 19:29:16 +00:00
] ,
2019-11-04 16:55:03 +00:00
" 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.request " ,
" re2o.context_processors.context_user " ,
" re2o.context_processors.context_optionnal_apps " ,
" re2o.context_processors.date_now " ,
]
2016-07-04 23:15:51 +00:00
} ,
2019-11-04 16:55:03 +00:00
}
2016-07-04 23:15:51 +00:00
]
2018-04-14 19:29:16 +00:00
# The WSGI module to use in a server environment
2019-11-04 16:55:03 +00:00
WSGI_APPLICATION = " re2o.wsgi.application "
2016-07-04 23:15:51 +00:00
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
2019-11-04 16:55:03 +00:00
LANGUAGE_CODE = " en "
2018-04-14 19:29:16 +00:00
USE_I18N = True
USE_L10N = True
2018-04-10 22:07:26 +00:00
# Proritary location search for translations
# then searches in {app}/locale/ for app in INSTALLED_APPS
2018-04-14 19:29:16 +00:00
# Use only absolute paths with '/' delimiters even on Windows
2018-04-10 22:07:26 +00:00
LOCALE_PATHS = [
2018-04-14 19:29:16 +00:00
# For translations outside of apps
2019-11-04 16:55:03 +00:00
os . path . join ( BASE_DIR , " templates " , " locale " ) . replace ( " \\ " , " / " )
2018-04-16 18:07:54 +00:00
]
2019-11-04 16:55:03 +00:00
LANGUAGES = [ ( " en " , _ ( " English " ) ) , ( " fr " , _ ( " French " ) ) ]
2018-04-10 22:07:26 +00:00
2018-04-14 19:29:16 +00:00
# Should use time zone ?
2016-07-04 23:15:51 +00:00
USE_TZ = True
2018-04-14 19:29:16 +00:00
# Router config for database
2021-02-13 14:52:41 +00:00
DATABASE_ROUTERS = [ ]
2020-05-21 16:34:14 +00:00
if " LOCAL_ROUTERS " in globals ( ) :
DATABASE_ROUTERS + = LOCAL_ROUTERS
2016-07-25 21:54:40 +00:00
2018-04-14 19:29:16 +00:00
# django-bootstrap3 config
2016-07-04 23:15:51 +00:00
BOOTSTRAP3 = {
2021-01-24 13:36:21 +00:00
" css_url " : " /javascript/bootstrap/css/bootstrap.min.css " ,
" javascript_url " : " /javascript/bootstrap/js/bootstrap.min.js " ,
2019-11-04 16:55:03 +00:00
" jquery_url " : " /javascript/jquery/jquery.min.js " ,
" base_url " : " /javascript/bootstrap/ " ,
" include_jquery " : True ,
2018-04-14 19:29:16 +00:00
}
2019-11-04 16:55:03 +00:00
BOOTSTRAP_BASE_URL = " /javascript/bootstrap/ "
2016-07-04 23:15:51 +00:00
2018-04-14 19:29:16 +00:00
# Directories where collectstatic should look for static files
# Use only absolute paths with '/' delimiters even on Windows
2016-07-04 23:15:51 +00:00
STATICFILES_DIRS = (
2019-11-04 16:55:03 +00:00
os . path . join ( BASE_DIR , " static " ) . replace ( " \\ " , " / " ) ,
2018-09-19 11:37:10 +00:00
" /usr/share/fonts-font-awesome/ " ,
2021-01-24 13:36:21 +00:00
" /usr/share/javascript/ " ,
2016-07-04 23:15:51 +00:00
)
2018-04-15 17:26:28 +00:00
# Directory where the static files served by the server are stored
2019-11-04 16:55:03 +00:00
STATIC_ROOT = os . path . join ( BASE_DIR , " static_files " )
2018-04-14 19:29:16 +00:00
# The URL to access the static files
2019-11-04 16:55:03 +00:00
STATIC_URL = " /static/ "
2018-04-15 17:26:28 +00:00
# Directory where the media files served by the server are stored
2019-11-04 16:55:03 +00:00
MEDIA_ROOT = os . path . join ( BASE_DIR , " media " ) . replace ( " \\ " , " / " )
2018-04-15 17:26:28 +00:00
# The URL to access the static files
2019-11-04 16:55:03 +00:00
MEDIA_URL = os . path . join ( BASE_DIR , " /media/ " )
2016-07-10 14:39:21 +00:00
2018-04-14 19:29:16 +00:00
# Models to use for graphs
2019-11-04 16:55:03 +00:00
GRAPH_MODELS = { " all_applications " : True , " group_models " : True }
2018-04-19 22:00:49 +00:00
2020-04-19 18:06:34 +00:00
# Timeout when sending emails through Django (in seconds)
EMAIL_TIMEOUT = 10
2021-02-09 12:01:42 +00:00
AUTH_PASSWORD_VALIDATORS = [
{
2021-02-10 10:06:09 +00:00
" NAME " : " django.contrib.auth.password_validation.UserAttributeSimilarityValidator " ,
2021-02-09 12:01:42 +00:00
} ,
{
2021-02-10 10:06:09 +00:00
" NAME " : " django.contrib.auth.password_validation.MinimumLengthValidator " ,
2021-02-09 12:01:42 +00:00
} ,
{
2021-02-10 10:06:09 +00:00
" NAME " : " django.contrib.auth.password_validation.CommonPasswordValidator " ,
2021-02-09 12:01:42 +00:00
} ,
{
2021-02-10 10:06:09 +00:00
" NAME " : " django.contrib.auth.password_validation.NumericPasswordValidator " ,
2021-02-09 12:01:42 +00:00
} ,
2021-02-10 10:06:09 +00:00
]
2021-02-09 12:01:42 +00:00
2018-04-20 18:10:45 +00:00
# Activate API
2019-11-04 16:55:03 +00:00
if " api " in INSTALLED_APPS :
2018-04-20 18:10:45 +00:00
from api . settings import *
2019-11-04 16:55:03 +00:00
2018-04-21 19:48:33 +00:00
INSTALLED_APPS + = API_APPS