# -*- coding: utf-8 -*- """ Django common settings for GestionÉvénementiel Everything which is supposed to be identical between the production server and the local development server should be here. We also load the secrets in this file. """ import os from . import secret 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") DBNAME = import_secret("DBNAME") DBUSER = import_secret("DBUSER") DBPASSWD = import_secret("DBPASSWD") REDIS_PASSWD = import_secret("REDIS_PASSWD") REDIS_DB = import_secret("REDIS_DB") REDIS_HOST = import_secret("REDIS_HOST") REDIS_PORT = import_secret("REDIS_PORT") CREATE_USER_KEY = import_secret("CREATE_USER_KEY") BASE_DIR = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ) INSTALLED_APPS = [ 'communication.apps.CommunicationConfig', 'equipment.apps.EquipmentConfig', 'event.apps.EventConfig', 'users.apps.UsersConfig', 'shared.apps.SharedConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'channels', 'rest_framework', 'bootstrapform', 'widget_tweaks', 'api', ] MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.IsAdminUser', ], 'PAGE_SIZE': 10 } ROOT_URLCONF = 'evenementiel.urls' STATIC_URL = "/static/" MEDIA_URL = "/media/" LOGIN_REDIRECT_URL = 'shared:home' LOGOUT_REDIRECT_URL = 'shared:home' AUTH_USER_MODEL = "users.User" 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', 'shared.shared.context_processor', ], }, }, ] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': DBNAME, 'USER': DBUSER, 'PASSWORD': DBPASSWD, 'PORT': 5432, 'HOST': 'localhost', } } CHANNEL_LAYERS = { "default": { "BACKEND": "asgi_redis.RedisChannelLayer", "CONFIG": { "hosts": [( "redis://:{passwd}@{host}:{port}/{db}" .format(passwd=REDIS_PASSWD, host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB) )], }, "ROUTING": "evenementiel.routing.channel_routing", } } # Password validation # https://docs.djangoproject.com/en/1.9/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'}, ] # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True