settings.py 6.31 KB
Newer Older
1
# -*- mode: python; coding: utf-8 -*-
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# Re2o est un logiciel d'administration développé initiallement au rezometz. Il
# se veut agnostique au réseau considéré, de manière à être installable en
# quelques clics.
#
# Copyright © 2017  Gabriel Détraz
# Copyright © 2017  Goulven Kermarec
# 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.

chirac's avatar
chirac committed
24 25 26 27 28 29 30 31 32 33 34 35
"""
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/
"""

36 37
from __future__ import unicode_literals

chirac's avatar
chirac committed
38
import os
Gabriel Detraz's avatar
Gabriel Detraz committed
39
from .settings_local import *
Maël Kervella's avatar
Maël Kervella committed
40
from django.utils.translation import ugettext_lazy as _
chirac's avatar
chirac committed
41

42 43
# The root directory for the project
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
chirac's avatar
chirac committed
44 45
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

46 47 48
# Auth definition
PASSWORD_HASHERS = (
    're2o.login.SSHAPasswordHasher',
49 50
    're2o.login.MD5PasswordHasher',
    're2o.login.CryptPasswordHasher',
51 52
    'django.contrib.auth.hashers.PBKDF2PasswordHasher',
)
53 54 55
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
56

chirac's avatar
chirac committed
57
# Application definition
58
DJANGO_CONTRIB_APPS = (
chirac's avatar
chirac committed
59 60 61 62 63 64
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
65 66
)
EXTERNAL_CONTRIB_APPS = (
chirac's avatar
chirac committed
67
    'bootstrap3',
68 69 70 71
    'rest_framework',
    'reversion',
)
LOCAL_APPS = (
chirac's avatar
chirac committed
72 73 74 75 76
    'users',
    'machines',
    'cotisations',
    'topologie',
    'search',
chirac's avatar
chirac committed
77
    're2o',
78
    'preferences',
chirac's avatar
chirac committed
79
    'logs',
80 81 82 83 84 85 86
)
INSTALLED_APPS = (
    DJANGO_CONTRIB_APPS +
    EXTERNAL_CONTRIB_APPS +
    LOCAL_APPS +
    OPTIONNAL_APPS
)
chirac's avatar
chirac committed
87 88
MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
89
    'django.middleware.locale.LocaleMiddleware',
chirac's avatar
chirac committed
90 91 92 93 94 95 96
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
97
    'reversion.middleware.RevisionMiddleware',
chirac's avatar
chirac committed
98
)
99 100 101

AUTHENTICATION_BACKENDS = ['re2o.login.RecryptBackend']

102 103 104 105 106 107 108 109 110 111
# Include debug_toolbar middleware if activated
if 'debug_toolbar' in INSTALLED_APPS:
    # Include this middleware at the beggining
    MIDDLEWARE_CLASSES = (
        'debug_toolbar.middleware.DebugToolbarMiddleware',
    ) + MIDDLEWARE_CLASSES
    # Change the default show_toolbar middleware
    DEBUG_TOOLBAR_CONFIG = {
        'SHOW_TOOLBAR_CALLBACK': 're2o.middleware.show_debug_toolbar'
    }
chirac's avatar
chirac committed
112

113
# The root url module to define the project URLs
chirac's avatar
chirac committed
114 115
ROOT_URLCONF = 're2o.urls'

116
# The templates configuration (see Django documentation)
chirac's avatar
chirac committed
117 118 119 120
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
121 122
            # Use only absolute paths with '/' delimiters even on Windows
            os.path.join(BASE_DIR, 'templates').replace('\\', '/'),
123
            os.path.join(BASE_DIR, 'media', 'templates').replace('\\', '/'),
124
        ],
chirac's avatar
chirac committed
125 126 127 128 129 130 131
        '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',
132
                'django.template.context_processors.request',
133
                're2o.context_processors.context_user',
134
                're2o.context_processors.date_now',
chirac's avatar
chirac committed
135 136 137 138 139
            ],
        },
    },
]

140
# The WSGI module to use in a server environment
chirac's avatar
chirac committed
141 142 143 144
WSGI_APPLICATION = 're2o.wsgi.application'

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
145
LANGUAGE_CODE = 'en'
146 147
USE_I18N = True
USE_L10N = True
148 149
# Proritary location search for translations
# then searches in {app}/locale/ for app in INSTALLED_APPS
150
# Use only absolute paths with '/' delimiters even on Windows
151
LOCALE_PATHS = [
152 153
    # For translations outside of apps
    os.path.join(BASE_DIR, 'templates', 'locale').replace('\\', '/')
154
]
Maël Kervella's avatar
Maël Kervella committed
155 156 157 158
LANGUAGES = [
    ('en', _('English')),
    ('fr', _('French'))
]
159

160
# Should use time zone ?
chirac's avatar
chirac committed
161 162
USE_TZ = True

163
# Router config for database
164 165
DATABASE_ROUTERS = ['ldapdb.router.Router']

166
# django-bootstrap3 config
chirac's avatar
chirac committed
167
BOOTSTRAP3 = {
168
    'jquery_url': '/javascript/jquery/jquery.min.js',
169
    'base_url': '/javascript/bootstrap/',
170 171
    'include_jquery': True,
}
172
BOOTSTRAP_BASE_URL = '/javascript/bootstrap/'
chirac's avatar
chirac committed
173

174 175
# Directories where collectstatic should look for static files
# Use only absolute paths with '/' delimiters even on Windows
chirac's avatar
chirac committed
176
STATICFILES_DIRS = (
177
    os.path.join(BASE_DIR, 'static').replace('\\', '/'),
erdnaxe's avatar
erdnaxe committed
178
    "/usr/share/fonts-font-awesome/",
chirac's avatar
chirac committed
179
)
180
# Directory where the static files served by the server are stored
181
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
182 183
# The URL to access the static files
STATIC_URL = '/static/'
184
# Directory where the media files served by the server are stored
185
MEDIA_ROOT = os.path.join(BASE_DIR, 'media').replace('\\', '/')
186
# The URL to access the static files
Charlie Jacomme's avatar
Charlie Jacomme committed
187
MEDIA_URL = os.path.join(BASE_DIR,'/media/')
188

189
# Models to use for graphs
190
GRAPH_MODELS = {
191 192
    'all_applications': True,
    'group_models': True,
193
}
Maël Kervella's avatar
Maël Kervella committed
194

195 196 197
# Activate API
if 'api' in INSTALLED_APPS:
    from api.settings import *
198
    INSTALLED_APPS += API_APPS