2020-02-18 20:30:26 +00:00
|
|
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
2019-07-08 09:08:07 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2019-07-07 20:49:02 +00:00
|
|
|
|
|
|
|
import os
|
2019-08-11 12:47:44 +00:00
|
|
|
import sys
|
2019-07-07 20:49:02 +00:00
|
|
|
|
2019-07-08 09:08:07 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
2019-07-07 20:49:02 +00:00
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
2020-01-27 20:49:02 +00:00
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
2019-08-14 13:17:14 +00:00
|
|
|
APPS_DIR = os.path.realpath(os.path.join(BASE_DIR, "apps"))
|
2019-08-11 12:47:44 +00:00
|
|
|
sys.path.append(APPS_DIR)
|
2019-07-07 20:49:02 +00:00
|
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
|
|
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
|
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
2019-07-08 09:08:07 +00:00
|
|
|
SECRET_KEY = 'CHANGE_ME_IN_LOCAL_SETTINGS!'
|
2019-07-07 20:49:02 +00:00
|
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
|
DEBUG = True
|
|
|
|
|
2019-07-08 09:08:07 +00:00
|
|
|
ADMINS = (
|
2019-07-08 12:22:41 +00:00
|
|
|
# ('Admin', 'webmaster@example.com'),
|
2019-07-08 09:08:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
SITE_ID = 1
|
|
|
|
|
|
|
|
ALLOWED_HOSTS = []
|
2019-07-07 20:49:02 +00:00
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
2019-07-08 11:51:15 +00:00
|
|
|
# Theme overrides Django Admin templates
|
2019-08-10 17:00:16 +00:00
|
|
|
# 'theme',
|
2019-07-08 11:51:15 +00:00
|
|
|
|
2019-07-17 09:17:50 +00:00
|
|
|
# External apps
|
|
|
|
'polymorphic',
|
|
|
|
'reversion',
|
2019-08-11 14:21:25 +00:00
|
|
|
'crispy_forms',
|
2019-08-13 16:22:19 +00:00
|
|
|
'django_tables2',
|
2019-07-08 11:51:15 +00:00
|
|
|
# Django contrib
|
2019-07-07 20:49:02 +00:00
|
|
|
'django.contrib.admin',
|
2019-07-08 09:08:07 +00:00
|
|
|
'django.contrib.admindocs',
|
2019-07-07 20:49:02 +00:00
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
2019-07-08 09:08:07 +00:00
|
|
|
'django.contrib.sites',
|
2019-07-07 20:49:02 +00:00
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
2020-02-06 22:29:17 +00:00
|
|
|
# API
|
|
|
|
'rest_framework',
|
2020-02-17 18:25:33 +00:00
|
|
|
'rest_framework.authtoken',
|
2020-02-08 19:23:17 +00:00
|
|
|
# Autocomplete
|
|
|
|
'dal',
|
|
|
|
'dal_select2',
|
2020-02-21 14:24:29 +00:00
|
|
|
# turbolinks
|
|
|
|
'turbolinks',
|
2019-07-08 11:51:15 +00:00
|
|
|
|
|
|
|
# Note apps
|
2019-07-16 10:43:23 +00:00
|
|
|
'activity',
|
|
|
|
'member',
|
2019-07-08 12:30:58 +00:00
|
|
|
'note',
|
2020-02-17 18:44:56 +00:00
|
|
|
'api',
|
2019-07-07 20:49:02 +00:00
|
|
|
]
|
2020-02-02 14:43:34 +00:00
|
|
|
LOGIN_REDIRECT_URL = '/note/transfer/'
|
2019-07-07 20:49:02 +00:00
|
|
|
|
|
|
|
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',
|
2019-07-08 09:08:07 +00:00
|
|
|
'django.contrib.admindocs.middleware.XViewMiddleware',
|
2019-07-07 20:49:02 +00:00
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
2019-07-08 09:08:07 +00:00
|
|
|
'django.middleware.locale.LocaleMiddleware',
|
|
|
|
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
2020-02-21 14:24:29 +00:00
|
|
|
'turbolinks.middleware.TurbolinksMiddleware',
|
2019-07-07 20:49:02 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
ROOT_URLCONF = 'note_kfet.urls'
|
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
2019-08-14 13:17:14 +00:00
|
|
|
'DIRS': [os.path.join(BASE_DIR, 'templates')],
|
2019-07-07 20:49:02 +00:00
|
|
|
'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',
|
2019-08-13 16:22:19 +00:00
|
|
|
'django.template.context_processors.request',
|
2019-07-07 20:49:02 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
WSGI_APPLICATION = 'note_kfet.wsgi.application'
|
|
|
|
|
|
|
|
# Password validation
|
|
|
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
|
|
|
|
|
|
|
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',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2019-07-08 12:22:41 +00:00
|
|
|
# Django Guardian object permissions
|
|
|
|
|
|
|
|
AUTHENTICATION_BACKENDS = (
|
|
|
|
'django.contrib.auth.backends.ModelBackend', # this is default
|
|
|
|
'guardian.backends.ObjectPermissionBackend',
|
|
|
|
)
|
2019-07-07 20:49:02 +00:00
|
|
|
|
2020-02-06 22:29:17 +00:00
|
|
|
REST_FRAMEWORK = {
|
|
|
|
# Use Django's standard `django.contrib.auth` permissions,
|
|
|
|
# or allow read-only access for unauthenticated users.
|
|
|
|
'DEFAULT_PERMISSION_CLASSES': [
|
2020-02-17 18:44:56 +00:00
|
|
|
# TODO Maybe replace it with our custom permissions system
|
2020-02-06 22:29:17 +00:00
|
|
|
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
2020-02-17 18:25:33 +00:00
|
|
|
],
|
|
|
|
'DEFAULT_AUTHENTICATION_CLASSES': [
|
|
|
|
'rest_framework.authentication.TokenAuthentication',
|
2020-02-06 22:29:17 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2019-08-14 13:17:14 +00:00
|
|
|
ANONYMOUS_USER_NAME = None # Disable guardian anonymous user
|
2019-07-23 00:11:24 +00:00
|
|
|
|
2019-07-17 09:17:50 +00:00
|
|
|
GUARDIAN_GET_CONTENT_TYPE = 'polymorphic.contrib.guardian.get_polymorphic_base_content_type'
|
|
|
|
|
2019-07-07 20:49:02 +00:00
|
|
|
# Internationalization
|
|
|
|
# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
|
|
|
|
2019-07-08 09:16:29 +00:00
|
|
|
LANGUAGE_CODE = 'en'
|
2019-07-07 20:49:02 +00:00
|
|
|
|
2019-07-08 09:08:07 +00:00
|
|
|
LANGUAGES = [
|
2020-02-06 20:42:17 +00:00
|
|
|
('de', _('German')),
|
2019-07-08 09:16:29 +00:00
|
|
|
('en', _('English')),
|
|
|
|
('fr', _('French')),
|
2019-07-08 09:08:07 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
TIME_ZONE = 'Europe/Paris'
|
2019-07-07 20:49:02 +00:00
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
USE_L10N = True
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
2019-08-14 13:17:14 +00:00
|
|
|
LOCALE_PATHS = [os.path.join(BASE_DIR, "locale")]
|
|
|
|
|
2019-07-07 20:49:02 +00:00
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
|
|
|
|
2019-07-08 09:08:07 +00:00
|
|
|
# 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/"
|
2019-08-10 17:00:16 +00:00
|
|
|
STATIC_ROOT = os.path.realpath(__file__)
|
|
|
|
STATICFILES_DIRS = [
|
2019-08-14 13:17:14 +00:00
|
|
|
os.path.join(BASE_DIR, 'static')]
|
2019-08-10 17:00:16 +00:00
|
|
|
|
|
|
|
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
2019-08-13 16:22:19 +00:00
|
|
|
DJANGO_TABLES2_TEMPLATE = 'django_tables2/bootstrap4.html'
|
2019-07-08 09:08:07 +00:00
|
|
|
# URL prefix for static files.
|
|
|
|
# Example: "http://example.com/static/", "http://static.example.com/"
|
2019-07-07 20:49:02 +00:00
|
|
|
STATIC_URL = '/static/'
|
2019-07-08 09:08:07 +00:00
|
|
|
|
2019-07-23 00:13:09 +00:00
|
|
|
ALIAS_VALIDATOR_REGEX = r''
|
|
|
|
|