From 57c29bf01d4db1d327e6e8d78e92f3dfc80e6c2e Mon Sep 17 00:00:00 2001 From: James Graham Date: Thu, 16 Apr 2020 14:07:14 +0100 Subject: [PATCH] refactor: Begin import of customisation app --- breccia_mapper/settings.py | 25 +++++++++++++++++++++++++ breccia_mapper/views.py | 4 +++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/breccia_mapper/settings.py b/breccia_mapper/settings.py index 16d6569..29b27d3 100644 --- a/breccia_mapper/settings.py +++ b/breccia_mapper/settings.py @@ -14,6 +14,8 @@ https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ """ import collections +import logging +import logging.config import pathlib from django.urls import reverse_lazy @@ -241,6 +243,12 @@ LOGGING = { } } +# Initialise logger now so we can use it in this file + +LOGGING_CONFIG = None +logging.config.dictConfig(LOGGING) +logger = logging.getLogger(__name__) + # Admin panel variables @@ -262,3 +270,20 @@ CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend' BOOTSTRAP4 = { 'include_jquery': 'full', } + + +# Import customisation app settings if present + +TEMPLATE_NAME_INDEX = 'index.html' + +try: + from custom.settings import ( + CUSTOMISATION_NAME, + TEMPLATE_NAME_INDEX + ) + logger.info("Loaded customisation app: %s", CUSTOMISATION_NAME) + + INSTALLED_APPS.append('custom') + +except ImportError as e: + logger.info("No customisation app loaded: %s", e) diff --git a/breccia_mapper/views.py b/breccia_mapper/views.py index 272f7c9..ff539f6 100644 --- a/breccia_mapper/views.py +++ b/breccia_mapper/views.py @@ -4,8 +4,10 @@ Views belonging to the core of the project. These views don't represent any of the models in the apps. """ +from django.conf import settings from django.views.generic import TemplateView class IndexView(TemplateView): - template_name = 'index.html' + # Template set in Django settings file - may be customised by a customisation app + template_name = settings.TEMPLATE_NAME_INDEX