From d16bf5e6b0b6147c973bdcbb952e8d35d0f0f6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sat, 9 May 2020 11:49:05 +0200 Subject: [PATCH] Merge local and dev settings --- cof/settings/dev.py | 55 ------------------------------------------- cof/settings/local.py | 44 +++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 61 deletions(-) delete mode 100644 cof/settings/dev.py diff --git a/cof/settings/dev.py b/cof/settings/dev.py deleted file mode 100644 index d287eab8..00000000 --- a/cof/settings/dev.py +++ /dev/null @@ -1,55 +0,0 @@ -""" -Django development settings for the cof project. -The settings that are not listed here are imported from .common -""" - -import os - -from .common import * # NOQA -from .common import INSTALLED_APPS, MIDDLEWARE, TESTING - -EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" - -DEBUG = True - -if TESTING: - PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"] - -# As long as these apps are not ready for production, they are only available -# in development mode -INSTALLED_APPS += ["events", "bds", "clubs"] - - -# --- -# Apache static/media config -# --- - -STATIC_URL = "/static/" -STATIC_ROOT = "/srv/gestiocof/static/" - -MEDIA_ROOT = "/srv/gestiocof/media/" -MEDIA_URL = "/media/" - - -# --- -# Debug tool bar -# --- - - -def show_toolbar(request): - """ - On ne veut pas la vérification de INTERNAL_IPS faite par la debug-toolbar - car cela interfère avec l'utilisation de Vagrant. En effet, l'adresse de la - machine physique n'est pas forcément connue, et peut difficilement être - mise dans les INTERNAL_IPS. - """ - env_no_ddt = bool(os.environ.get("DJANGO_NO_DDT", None)) - return DEBUG and not env_no_ddt and not request.path.startswith("/admin/") - - -if not TESTING: - INSTALLED_APPS += ["debug_toolbar"] - - MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware"] + MIDDLEWARE - - DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar} diff --git a/cof/settings/local.py b/cof/settings/local.py index 06cdf4a0..789ec12b 100644 --- a/cof/settings/local.py +++ b/cof/settings/local.py @@ -1,14 +1,27 @@ """ -Django local settings for the cof project. +Django local development settings for the cof project. The settings that are not listed here are imported from .common """ import os -from .dev import * # NOQA -from .dev import BASE_DIR +from .common import * # NOQA +from .common import BASE_DIR, INSTALLED_APPS, MIDDLEWARE, TESTING + +EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + +DEBUG = True + +if TESTING: + PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"] + +# As long as these apps are not ready for production, they are only available +# in development mode +INSTALLED_APPS += ["events", "bds", "clubs"] + +STATIC_URL = "/static/" +MEDIA_URL = os.path.join(BASE_DIR, "media") -# Use sqlite for local development DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", @@ -27,5 +40,24 @@ CHANNEL_LAYERS = { } } -# No need to run collectstatic -> unset STATIC_ROOT -STATIC_ROOT = None + +# --- +# Debug tool bar +# --- + + +def show_toolbar(request): + """ + On ne veut pas la vérification de INTERNAL_IPS faite par la debug-toolbar + car cela interfère avec l'utilisation de Vagrant. En effet, l'adresse de la + machine physique n'est pas forcément connue, et peut difficilement être + mise dans les INTERNAL_IPS. + """ + env_no_ddt = bool(os.environ.get("DJANGO_NO_DDT", None)) + return DEBUG and not env_no_ddt and not request.path.startswith("/admin/") + + +if not TESTING: + INSTALLED_APPS += ["debug_toolbar"] + MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware"] + MIDDLEWARE + DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar}