ernestophone.ens.fr/Ernestophone/settings/common.py

121 lines
2.9 KiB
Python
Raw Normal View History

2015-03-17 19:03:51 +01:00
import os
try:
from . import secret
except ImportError:
raise ImportError(
"The secret.py file is missing.\n"
"For a development environment, simply copy secret_example.py"
)
def import_secret(name):
"""
Shorthand for importing a value from the secret module and raising an
informative exception if a secret is missing.
"""
try:
return getattr(secret, name)
except AttributeError:
raise RuntimeError("Secret missing: {}".format(name))
SECRET_KEY = import_secret("SECRET_KEY")
ADMINS = import_secret("ADMINS")
SERVER_EMAIL = import_secret("SERVER_EMAIL")
2015-03-17 19:03:51 +01:00
DBNAME = import_secret("DBNAME")
DBUSER = import_secret("DBUSER")
DBPASSWD = import_secret("DBPASSWD")
2015-03-17 19:03:51 +01:00
2017-10-15 16:34:39 +02:00
ACCOUNT_CREATION_PASS = import_secret("ACCOUNT_CREATION_PASS")
2015-03-17 19:03:51 +01:00
BASE_DIR = os.path.join(
os.path.dirname(__file__), "..", ".."
)
2015-03-17 19:03:51 +01:00
INSTALLED_APPS = [
2015-03-17 19:03:51 +01:00
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'gestion',
'partitions',
2015-04-13 18:56:43 +02:00
'calendrier',
2015-07-22 22:08:59 +02:00
'propositions',
'pads',
]
2015-03-17 19:03:51 +01:00
2018-01-05 00:06:24 +01:00
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
2015-03-17 19:03:51 +01:00
'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',
]
2015-03-17 19:03:51 +01:00
ROOT_URLCONF = "Ernestophone.urls"
TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
2018-01-05 00:24:42 +01:00
'DIRS': [],
'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',
],
}
}]
2018-01-05 00:06:24 +01:00
WSGI_APPLICATION = "Ernestophone.wsgi.application"
DATABASES = {
"default": {
2018-01-05 00:06:24 +01:00
"ENGINE": "django.db.backends.postgresql",
"NAME": DBNAME,
"USER": DBUSER,
"PASSWORD": DBPASSWD,
"HOST": "localhost",
}
}
2018-01-05 00:06:24 +01:00
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',
},
]
2015-03-17 19:03:51 +01:00
# I18n
2015-03-17 19:03:51 +01:00
LANGUAGE_CODE = 'fr-fr'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
2015-03-17 19:03:51 +01:00
)
AUTH_PROFILE_MODEL = 'gestion.ErnestoUser'
LOGIN_URL = "/login"