Initial commit
This commit is contained in:
commit
793bb6a488
182 changed files with 17153 additions and 0 deletions
6
settings/README
Normal file
6
settings/README
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
This settings system works on two levels:
|
||||
- aemo.py : global project settings
|
||||
- __init__.py : instance specific settings (passwords, keys, etc.)
|
||||
|
||||
__init__.py should import aemo.py.
|
||||
__init__.py should *NOT* be committed in the vcs (it is in .gitignore).
|
||||
189
settings/aemo.py
Normal file
189
settings/aemo.py
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
from ipaddress import IPv4Network
|
||||
from pathlib import Path
|
||||
from django.contrib.messages import constants as messages
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['localhost']
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'aemo_fr',
|
||||
}
|
||||
}
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'dal', # dal: django-auto-complete
|
||||
'dal_select2',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.postgres',
|
||||
|
||||
'city_ch_autocomplete',
|
||||
'django_countries',
|
||||
'django_otp',
|
||||
'django_otp.plugins.otp_totp',
|
||||
'django_otp.plugins.otp_static',
|
||||
'two_factor',
|
||||
'tinymce',
|
||||
|
||||
'aemo',
|
||||
'archive',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.http.ConditionalGetMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django_otp.middleware.OTPMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'common.middleware.LoginRequiredMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'common.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [
|
||||
BASE_DIR / 'templates',
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.template.context_processors.media',
|
||||
'django.template.context_processors.static',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.template.context_processors.request',
|
||||
],
|
||||
'libraries': {
|
||||
'my_tags': 'aemo.templatetags.my_tags',
|
||||
},
|
||||
'builtins': [
|
||||
'aemo.templatetags.my_tags', 'django.templatetags.static',
|
||||
],
|
||||
},
|
||||
|
||||
},
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'NAME': 'django-text',
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'autoescape': False,
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'
|
||||
|
||||
WSGI_APPLICATION = 'common.wsgi.application'
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/2.1/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',
|
||||
},
|
||||
]
|
||||
|
||||
AUTH_USER_MODEL = 'aemo.Utilisateur'
|
||||
|
||||
LOGIN_URL = 'two_factor:login'
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
EXEMPT_2FA_NETWORKS = [IPv4Network('127.0.0.0/30')]
|
||||
# These users should not have TOTP devices configured.
|
||||
EXEMPT_2FA_USERS = []
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.1/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'fr'
|
||||
LANGUAGES = [('fr', 'Français')]
|
||||
|
||||
TIME_ZONE = 'Europe/Zurich'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
FORMAT_MODULE_PATH = ['common.formats']
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = BASE_DIR / 'static'
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = BASE_DIR / 'media'
|
||||
|
||||
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
||||
|
||||
DEFAULT_FROM_EMAIL = 'secretariat@fondation-transit.ch'
|
||||
|
||||
# For django-countries
|
||||
COUNTRIES_FIRST = ['CH']
|
||||
# https://github.com/SmileyChris/django-countries/issues/314
|
||||
COUNTRIES_OVERRIDE = {
|
||||
"XK": {"name": "Kosovo", "ioc_code": "KOS"},
|
||||
}
|
||||
|
||||
TINYMCE_DEFAULT_CONFIG = {
|
||||
'autosave_interval': '10s',
|
||||
'autosave_retention': '240m',
|
||||
'height': 360,
|
||||
'width': '100%',
|
||||
'cleanup_on_startup': True,
|
||||
'entity_encoding': 'raw',
|
||||
'custom_undo_redo_levels': 20,
|
||||
'browser_spellcheck': True,
|
||||
'theme': 'silver',
|
||||
'plugins': 'autosave,lists',
|
||||
'toolbar1': 'preview bold italic underline bullist | undo redo restoredraft',
|
||||
'menubar': False,
|
||||
'statusbar': True,
|
||||
# Modern way is to use text-decoration: underline, however it is harder to clean
|
||||
# with sanitizer than simpler <u>.
|
||||
'formats': {
|
||||
'underline': {'inline': 'u', 'exact': True}
|
||||
},
|
||||
}
|
||||
|
||||
MESSAGE_TAGS = {
|
||||
messages.DEBUG: 'alert-info',
|
||||
messages.INFO: 'alert-info',
|
||||
messages.SUCCESS: 'alert-success',
|
||||
messages.WARNING: 'alert-warning',
|
||||
messages.ERROR: 'alert-danger',
|
||||
}
|
||||
|
||||
CRNE_RSA_PUBLIC_KEY = ''
|
||||
|
||||
# Les valeurs "POST_API_*" doivent être renseignées dans settings/__init__.py (non suivi dans le dépôt de code)
|
||||
POST_API_USER = ""
|
||||
POST_API_PASSWORD = ""
|
||||
14
settings/aemo_tests.py
Normal file
14
settings/aemo_tests.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from settings.aemo import * # noqa
|
||||
|
||||
SECRET_KEY = 'ForAutomatedTestsC9g'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'ci_test',
|
||||
'USER': 'runner',
|
||||
'PASSWORD': '',
|
||||
'HOST': 'postgres',
|
||||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
14
settings/dev_docker.py
Normal file
14
settings/dev_docker.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import dj_database_url
|
||||
import os
|
||||
|
||||
from ipaddress import IPv4Network
|
||||
|
||||
from settings.aemo import * # NOQA
|
||||
|
||||
|
||||
ALLOWED_HOSTS = os.environ["ALLOWED_HOSTS"].split(",")
|
||||
DATABASES = {"default": dj_database_url.parse(os.environ["DATABASE_URL"])}
|
||||
DEBUG = True
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
EXEMPT_2FA_NETWORKS = [IPv4Network('0.0.0.0/0')]
|
||||
SECRET_KEY = "no secret here"
|
||||
Loading…
Add table
Add a link
Reference in a new issue