base.py 3.73 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

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_cas_ng',
31 32
    'reversion',
    'reversion_compare',
Florent Chehab's avatar
Florent Chehab committed
33 34
    'rest_framework',
    'rest_framework.authtoken',
35
    'backend',
Florent Chehab's avatar
Florent Chehab committed
36
    'frontend',
Florent Chehab's avatar
Florent Chehab committed
37 38 39 40 41 42 43 44 45 46
]

MIDDLEWARE = [
    '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',
Florent Chehab's avatar
Florent Chehab committed
47
    'general.middleware.LoginRequiredMiddleware',
Florent Chehab's avatar
Florent Chehab committed
48 49
]

50
TESTING = "pytest" in sys.modules
Florent Chehab's avatar
Florent Chehab committed
51

52
ALLOWED_PHOTOS_EXTENSION = ["jpg", "jpeg", "png", "svg"]
53

Florent Chehab's avatar
Florent Chehab committed
54 55
INTERNAL_IPS = ['127.0.0.1']

Florent Chehab's avatar
Florent Chehab committed
56 57 58 59
LOGIN_URL = '/user/login'
LOGIN_EXEMPT_URLS = [LOGIN_URL,
                     '/admin/',
                     'api']
Florent Chehab's avatar
Florent Chehab committed
60 61 62 63

AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'django_cas_ng.backends.CASBackend',
Florent Chehab's avatar
linting  
Florent Chehab committed
64
]
Florent Chehab's avatar
Florent Chehab committed
65

Florent Chehab's avatar
Florent Chehab committed
66
CAS_SERVER_URL = 'https://cas.utc.fr/cas/'
Florent Chehab's avatar
Florent Chehab committed
67
CAS_APPLY_ATTRIBUTES_TO_USER = True
Florent Chehab's avatar
Florent Chehab committed
68 69 70 71
CAS_RENAME_ATTRIBUTES = {
    'mail': 'email',
    'givenName': 'first_name',
    'sn': 'last_name'
Florent Chehab's avatar
Florent Chehab committed
72 73
}

Florent Chehab's avatar
Florent Chehab committed
74 75 76 77 78 79 80 81 82 83 84
REST_FRAMEWORK = {
    # Use Django's standard `django.contrib.auth` permissions,
    '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
85
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
Florent Chehab's avatar
Florent Chehab committed
86

Florent Chehab's avatar
Florent Chehab committed
87
ROOT_URLCONF = 'general.urls'
Florent Chehab's avatar
Florent Chehab committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104

TEMPLATES = [
    {
        '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
105
WSGI_APPLICATION = 'general.wsgi.application'
Florent Chehab's avatar
Florent Chehab committed
106 107 108 109 110


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

Florent Chehab's avatar
Florent Chehab committed
111
# DB are set in other config files
Florent Chehab's avatar
Florent Chehab committed
112
DATABASES = {
Florent Chehab's avatar
Florent Chehab committed
113
    'default': None
Florent Chehab's avatar
Florent Chehab committed
114 115 116 117 118 119 120 121
}


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

AUTH_PASSWORD_VALIDATORS = [
    {
122 123
        'NAME': 'django.contrib.auth.password_validation.'
        'UserAttributeSimilarityValidator',
Florent Chehab's avatar
Florent Chehab committed
124 125
    },
    {
126 127
        'NAME': 'django.contrib.auth.password_validation.'
        'MinimumLengthValidator',
Florent Chehab's avatar
Florent Chehab committed
128 129
    },
    {
130 131
        'NAME': 'django.contrib.auth.password_validation.'
        'CommonPasswordValidator',
Florent Chehab's avatar
Florent Chehab committed
132 133
    },
    {
134 135
        'NAME': 'django.contrib.auth.password_validation.'
        'NumericPasswordValidator',
Florent Chehab's avatar
Florent Chehab committed
136 137 138 139 140 141 142
    },
]


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

Florent Chehab's avatar
Florent Chehab committed
143
LANGUAGE_CODE = 'fr-fr'
Florent Chehab's avatar
Florent Chehab committed
144 145 146 147 148
TIME_ZONE = 'Europe/Paris'
USE_I18N = True
USE_L10N = True
USE_TZ = True

Florent Chehab's avatar
Florent Chehab committed
149 150
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'