base.py 4.1 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1 2 3 4 5 6 7 8 9 10 11 12 13
"""
Django settings for outgoing_rex project.

Generated by 'django-admin startproject' using Django 2.0.3.

For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
"""

import os
Florent Chehab's avatar
Florent Chehab committed
14
from os.path import dirname
15
import sys
Florent Chehab's avatar
Florent Chehab committed
16

Florent Chehab's avatar
Florent Chehab committed
17 18

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Florent Chehab's avatar
Florent Chehab committed
19
BASE_DIR = dirname(dirname(dirname(os.path.abspath(__file__))))
Florent Chehab's avatar
Florent Chehab committed
20

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
##########
# Webpack loader related

WEBPACK_LOADER = {
    "DEFAULT": {
        "BUNDLE_DIR_NAME": "frontend_app/bundles/",
        "STATS_FILE": os.path.join(BASE_DIR, "../frontend/webpack-stats.json"),
    }
}

STATICFILES_DIRS = (
    os.path.join(
        BASE_DIR, "static/frontend_app/bundles/"
    ),  # We do this so that django's collectstatic copies or our bundles to the STATIC_ROOT or syncs them to whatever storage we use.
)
Florent Chehab's avatar
Florent Chehab committed
36

37 38 39 40 41

# End of webpack loader related
###########

# Application definition
Florent Chehab's avatar
Florent Chehab committed
42
INSTALLED_APPS = [
43 44 45 46 47 48 49 50 51 52 53 54 55
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "django_cas_ng",
    "reversion",
    "reversion_compare",
    "rest_framework",
    "rest_framework.authtoken",
    "backend_app",
    "frontend_app",
56
    "webpack_loader",
Florent Chehab's avatar
Florent Chehab committed
57 58 59
]

MIDDLEWARE = [
60 61 62 63 64 65 66 67
    "django.middleware.security.SecurityMiddleware",
    "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",
    "base_app.middleware.LoginRequiredMiddleware",
Florent Chehab's avatar
Florent Chehab committed
68 69
]

70
TESTING = "pytest" in sys.modules
Florent Chehab's avatar
Florent Chehab committed
71

72
ALLOWED_PHOTOS_EXTENSION = ["jpg", "jpeg", "png", "svg"]
73

74
INTERNAL_IPS = ["127.0.0.1"]
Florent Chehab's avatar
Florent Chehab committed
75

76 77
LOGIN_URL = "/user/login"
LOGIN_EXEMPT_URLS = [LOGIN_URL, "/admin/", "api"]
Florent Chehab's avatar
Florent Chehab committed
78 79

AUTHENTICATION_BACKENDS = [
80 81
    "django.contrib.auth.backends.ModelBackend",
    "django_cas_ng.backends.CASBackend",
Florent Chehab's avatar
linting  
Florent Chehab committed
82
]
Florent Chehab's avatar
Florent Chehab committed
83

84
CAS_SERVER_URL = "https://cas.utc.fr/cas/"
Florent Chehab's avatar
Florent Chehab committed
85
CAS_APPLY_ATTRIBUTES_TO_USER = True
86
CAS_RENAME_ATTRIBUTES = {"mail": "email", "givenName": "first_name", "sn": "last_name"}
Florent Chehab's avatar
Florent Chehab committed
87

Florent Chehab's avatar
Florent Chehab committed
88 89
REST_FRAMEWORK = {
    # Use Django's standard `django.contrib.auth` permissions,
90 91 92 93 94 95
    "DEFAULT_PERMISSION_CLASSES": (
        "rest_framework.permissions.DjangoModelPermissions",
    ),
    "DEFAULT_AUTHENTICATION_CLASSES": (
        "rest_framework.authentication.SessionAuthentication",
        "rest_framework.authentication.TokenAuthentication",
Florent Chehab's avatar
Florent Chehab committed
96 97 98
    ),
}

Florent Chehab's avatar
Florent Chehab committed
99
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
Florent Chehab's avatar
Florent Chehab committed
100

101
ROOT_URLCONF = "base_app.urls"
Florent Chehab's avatar
Florent Chehab committed
102 103 104

TEMPLATES = [
    {
105 106 107 108 109 110 111 112 113 114
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "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",
            ]
Florent Chehab's avatar
Florent Chehab committed
115
        },
116
    }
Florent Chehab's avatar
Florent Chehab committed
117 118
]

119
WSGI_APPLICATION = "base_app.wsgi.application"
Florent Chehab's avatar
Florent Chehab committed
120 121 122 123 124


# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases

Florent Chehab's avatar
Florent Chehab committed
125
# DB are set in other config files
126
DATABASES = {"default": None}
Florent Chehab's avatar
Florent Chehab committed
127 128 129 130 131 132 133


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

AUTH_PASSWORD_VALIDATORS = [
    {
134 135
        "NAME": "django.contrib.auth.password_validation."
        "UserAttributeSimilarityValidator"
Florent Chehab's avatar
Florent Chehab committed
136
    },
137 138 139
    {"NAME": "django.contrib.auth.password_validation." "MinimumLengthValidator"},
    {"NAME": "django.contrib.auth.password_validation." "CommonPasswordValidator"},
    {"NAME": "django.contrib.auth.password_validation." "NumericPasswordValidator"},
Florent Chehab's avatar
Florent Chehab committed
140 141 142 143 144 145
]


# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/

146 147
LANGUAGE_CODE = "fr-fr"
TIME_ZONE = "Europe/Paris"
Florent Chehab's avatar
Florent Chehab committed
148 149 150 151
USE_I18N = True
USE_L10N = True
USE_TZ = True

152 153
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = "/media/"