settings.py 5.32 KB
Newer Older
1
# -*- mode: python; coding: utf-8 -*-
lhark's avatar
lhark committed
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 *
chirac's avatar
chirac committed
40

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

45
46
47
48
49
# Auth definition
PASSWORD_HASHERS = (
    're2o.login.SSHAPasswordHasher',
    'django.contrib.auth.hashers.PBKDF2PasswordHasher',
)
Maël Kervella's avatar
Maël Kervella committed
50
51
52
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
53

chirac's avatar
chirac committed
54
# Application definition
Maël Kervella's avatar
Maël Kervella committed
55
DJANGO_CONTRIB_APPS = (
chirac's avatar
chirac committed
56
57
58
59
60
61
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
Maël Kervella's avatar
Maël Kervella committed
62
63
)
EXTERNAL_CONTRIB_APPS = (
chirac's avatar
chirac committed
64
    'bootstrap3',
Maël Kervella's avatar
Maël Kervella committed
65
66
67
68
    'rest_framework',
    'reversion',
)
LOCAL_APPS = (
chirac's avatar
chirac committed
69
70
71
72
73
    'users',
    'machines',
    'cotisations',
    'topologie',
    'search',
chirac's avatar
chirac committed
74
    're2o',
75
    'preferences',
chirac's avatar
chirac committed
76
    'logs',
Maël Kervella's avatar
Maël Kervella committed
77
78
79
80
81
82
83
84
    'api',
)
INSTALLED_APPS = (
    DJANGO_CONTRIB_APPS +
    EXTERNAL_CONTRIB_APPS +
    LOCAL_APPS +
    OPTIONNAL_APPS
)
chirac's avatar
chirac committed
85
86
MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
87
    'django.middleware.locale.LocaleMiddleware',
chirac's avatar
chirac committed
88
89
90
91
92
93
94
    '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',
95
    'reversion.middleware.RevisionMiddleware',
chirac's avatar
chirac committed
96
97
)

Maël Kervella's avatar
Maël Kervella committed
98
# The root url module to define the project URLs
chirac's avatar
chirac committed
99
100
ROOT_URLCONF = 're2o.urls'

Maël Kervella's avatar
Maël Kervella committed
101
# The templates configuration (see Django documentation)
chirac's avatar
chirac committed
102
103
104
105
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
Maël Kervella's avatar
Maël Kervella committed
106
107
108
            # Use only absolute paths with '/' delimiters even on Windows
            os.path.join(BASE_DIR, 'templates').replace('\\', '/'),
        ],
chirac's avatar
chirac committed
109
110
111
112
113
114
115
        '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',
116
                'django.template.context_processors.request',
117
                're2o.context_processors.context_user',
chirac's avatar
chirac committed
118
119
120
121
122
            ],
        },
    },
]

Maël Kervella's avatar
Maël Kervella committed
123
# The WSGI module to use in a server environment
chirac's avatar
chirac committed
124
125
126
127
WSGI_APPLICATION = 're2o.wsgi.application'

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
128
LANGUAGE_CODE = 'en'
Maël Kervella's avatar
Maël Kervella committed
129
130
USE_I18N = True
USE_L10N = True
131
132
# Proritary location search for translations
# then searches in {app}/locale/ for app in INSTALLED_APPS
Maël Kervella's avatar
Maël Kervella committed
133
# Use only absolute paths with '/' delimiters even on Windows
134
LOCALE_PATHS = [
Maël Kervella's avatar
Maël Kervella committed
135
136
    # For translations outside of apps
    os.path.join(BASE_DIR, 'templates', 'locale').replace('\\', '/')
137
138
]

Maël Kervella's avatar
Maël Kervella committed
139
# Should use time zone ?
chirac's avatar
chirac committed
140
141
USE_TZ = True

Maël Kervella's avatar
Maël Kervella committed
142
# Router config for database
143
144
DATABASE_ROUTERS = ['ldapdb.router.Router']

Maël Kervella's avatar
Maël Kervella committed
145
# django-bootstrap3 config
chirac's avatar
chirac committed
146
BOOTSTRAP3 = {
Maël Kervella's avatar
Maël Kervella committed
147
148
149
150
    'jquery_url': '/static/js/jquery-2.2.4.min.js',
    'base_url': '/static/bootstrap/',
    'include_jquery': True,
}
chirac's avatar
chirac committed
151
152
BOOTSTRAP_BASE_URL = '/static/bootstrap/'

Maël Kervella's avatar
Maël Kervella committed
153
154
# Directories where collectstatic should look for static files
# Use only absolute paths with '/' delimiters even on Windows
chirac's avatar
chirac committed
155
STATICFILES_DIRS = (
Maël Kervella's avatar
Maël Kervella committed
156
    os.path.join(BASE_DIR, 'static').replace('\\', '/'),
chirac's avatar
chirac committed
157
)
Gabriel Detraz's avatar
Gabriel Detraz committed
158
159
160
161
162

MEDIA_ROOT = '/var/www/re2o/media'

MEDIA_URL = '/media/'

163
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
Maël Kervella's avatar
Maël Kervella committed
164
165
166
167
# The URL to access the static files
STATIC_URL = '/static/'
# Directory where the media files serverd by the server are stored
MEDIA_ROOT = os.path.join(BASE_DIR, 'media').replace('\\', '/')
168

Maël Kervella's avatar
Maël Kervella committed
169
# Models to use for graphs
170
GRAPH_MODELS = {
Maël Kervella's avatar
Maël Kervella committed
171
172
    'all_applications': True,
    'group_models': True,
173
}