settings.py 4.41 KB
Newer Older
erdnaxe's avatar
erdnaxe committed
1
# -*- mode: python; coding: utf-8 -*-
erdnaxe's avatar
erdnaxe committed
2
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
erdnaxe's avatar
erdnaxe committed
3
# SPDX-License-Identifier: GPL-3.0-or-later
4 5 6

import os

erdnaxe's avatar
erdnaxe committed
7
from django.utils.translation import gettext_lazy as _
8

erdnaxe's avatar
erdnaxe committed
9 10
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
11 12

# Quick-start development settings - unsuitable for production
erdnaxe's avatar
erdnaxe committed
13
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
14

erdnaxe's avatar
erdnaxe committed
15 16
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'CHANGE_ME_IN_LOCAL_SETTINGS!'
17

erdnaxe's avatar
erdnaxe committed
18
# SECURITY WARNING: don't run with debug turned on in production!
erdnaxe's avatar
erdnaxe committed
19
DEBUG = False
erdnaxe's avatar
erdnaxe committed
20 21 22

ADMINS = (
    # ('Admin', 'webmaster@example.com'),
23 24
)

erdnaxe's avatar
erdnaxe committed
25
SITE_ID = 1
26

erdnaxe's avatar
erdnaxe committed
27
ALLOWED_HOSTS = []
28 29 30

# Application definition

erdnaxe's avatar
erdnaxe committed
31
INSTALLED_APPS = [
erdnaxe's avatar
erdnaxe committed
32 33 34
    # Theme overrides Django Admin templates
    'theme',

erdnaxe's avatar
erdnaxe committed
35 36 37 38
    # External apps
    'reversion',

    # Django contrib
39
    'django.contrib.admin',
erdnaxe's avatar
erdnaxe committed
40
    'django.contrib.admindocs',
41 42 43
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
erdnaxe's avatar
erdnaxe committed
44
    'django.contrib.sites',
45 46
    'django.contrib.messages',
    'django.contrib.staticfiles',
erdnaxe's avatar
erdnaxe committed
47 48

    # Med apps
49
    'users',
Med's avatar
Med committed
50 51
    'med',
    'media',
erdnaxe's avatar
erdnaxe committed
52
    'logs',
erdnaxe's avatar
erdnaxe committed
53
    'sporz',
erdnaxe's avatar
erdnaxe committed
54
]
55

erdnaxe's avatar
erdnaxe committed
56 57
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
58 59 60 61 62
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
erdnaxe's avatar
erdnaxe committed
63
    'django.contrib.admindocs.middleware.XViewMiddleware',
64
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
erdnaxe's avatar
erdnaxe committed
65 66 67
    'django.middleware.locale.LocaleMiddleware',
    'django.contrib.sites.middleware.CurrentSiteMiddleware',
]
68

Med's avatar
Med committed
69
ROOT_URLCONF = 'med.urls'
70 71 72 73

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
74
        'DIRS': [],
75 76 77 78 79 80 81 82 83 84 85 86 87
        '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',
            ],
        },
    },
]

Med's avatar
Med committed
88
WSGI_APPLICATION = 'med.wsgi.application'
89

erdnaxe's avatar
erdnaxe committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
erdnaxe's avatar
erdnaxe committed
105 106
        'NAME': 'django.contrib.auth.'
                'password_validation.UserAttributeSimilarityValidator',
erdnaxe's avatar
erdnaxe committed
107 108
    },
    {
erdnaxe's avatar
erdnaxe committed
109 110
        'NAME': 'django.contrib.auth.'
                'password_validation.MinimumLengthValidator',
erdnaxe's avatar
erdnaxe committed
111 112
    },
    {
erdnaxe's avatar
erdnaxe committed
113 114
        'NAME': 'django.contrib.auth.'
                'password_validation.CommonPasswordValidator',
erdnaxe's avatar
erdnaxe committed
115 116
    },
    {
erdnaxe's avatar
erdnaxe committed
117 118
        'NAME': 'django.contrib.auth.'
                'password_validation.NumericPasswordValidator',
erdnaxe's avatar
erdnaxe committed
119 120
    },
]
121 122

# Internationalization
erdnaxe's avatar
erdnaxe committed
123
# https://docs.djangoproject.com/en/2.2/topics/i18n/
124

erdnaxe's avatar
erdnaxe committed
125 126 127 128 129 130
LANGUAGE_CODE = 'en'

LANGUAGES = [
    ('en', _('English')),
    ('fr', _('French')),
]
131 132 133 134 135 136 137 138 139

TIME_ZONE = 'Europe/Paris'

USE_I18N = True

USE_L10N = True

USE_TZ = True

erdnaxe's avatar
erdnaxe committed
140 141
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
142

erdnaxe's avatar
erdnaxe committed
143 144 145 146 147 148 149 150 151 152 153 154
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'

# Med configuration
PAGINATION_NUMBER = 25
155

156
PASSWORD_HASHERS = [
erdnaxe's avatar
erdnaxe committed
157
    'django.contrib.auth.hashers.PBKDF2PasswordHasher',
158 159 160 161 162
    'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
    'django.contrib.auth.hashers.Argon2PasswordHasher',
    'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
    'med.login.SSHAPasswordHasher',
]
163

erdnaxe's avatar
erdnaxe committed
164
AUTH_USER_MODEL = 'users.User'
erdnaxe's avatar
erdnaxe committed
165 166 167

MAX_EMPRUNT = 5  # Max emprunts

erdnaxe's avatar
erdnaxe committed
168 169 170 171
try:
    from .settings_local import *
except ImportError:
    pass