From 1d02aea7738a337a0ec4022bdd124b514a0ee1ce Mon Sep 17 00:00:00 2001 From: bkfox Date: Mon, 15 May 2017 14:25:14 +0200 Subject: [PATCH] remove base_settings for one configuration file; Please update your instance's settings.py --- instance/base_settings.py | 144 -------------------------- instance/sample_settings.py | 194 ++++++++++++++++++++++++++++++++---- 2 files changed, 176 insertions(+), 162 deletions(-) delete mode 100755 instance/base_settings.py diff --git a/instance/base_settings.py b/instance/base_settings.py deleted file mode 100755 index 3f2a03b..0000000 --- a/instance/base_settings.py +++ /dev/null @@ -1,144 +0,0 @@ -import os -import sys -sys.path.insert(1, os.path.dirname(os.path.realpath(__file__))) - -BASE_DIR = os.path.dirname(os.path.dirname(__file__)) -PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__) + "/..") - -STATIC_URL = '/static/' -MEDIA_URL = '/media/' -SITE_MEDIA_URL = '/media/' -STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') -MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media') - -# Internationalization -USE_I18N = True -USE_L10N = True -USE_TZ = True - -LANGUAGE_CODE = os.environ.get('LANG') or 'en_US' -TIME_ZONE = 'UTC' # os.environ.get('TZ') or 'Europe/Brussels' - -try: - import locale - locale.setlocale(locale.LC_ALL, LANGUAGE_CODE) -except: - print( - 'Can not set locale {LC}. Is it available on you system? Hint: ' - 'Check /etc/locale.gen and rerun locale-gen as sudo if needed.' - .format(LC = LANGUAGE_CODE) - ) - pass - -# Application definition -INSTALLED_APPS = ( - 'aircox', - 'aircox_cms', - - 'jet', - 'wagtail.wagtailforms', - 'wagtail.wagtailredirects', - 'wagtail.wagtailembeds', - 'wagtail.wagtailsites', - 'wagtail.wagtailusers', - 'wagtail.wagtailsnippets', - 'wagtail.wagtaildocs', - 'wagtail.wagtailimages', - 'wagtail.wagtailsearch', - 'wagtail.wagtailadmin', - 'wagtail.wagtailcore', - 'wagtail.contrib.settings', - 'wagtail.contrib.modeladmin', - - 'modelcluster', - 'taggit', - 'honeypot', - - 'django.contrib.contenttypes', - 'django.contrib.auth', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'django.contrib.admin', -) - -MIDDLEWARE_CLASSES = ( - 'django.middleware.gzip.GZipMiddleware', - 'htmlmin.middleware.HtmlMinifyMiddleware', - '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', - 'django.middleware.security.SecurityMiddleware', - - 'wagtail.wagtailcore.middleware.SiteMiddleware', - 'wagtail.wagtailredirects.middleware.RedirectMiddleware', -) - - -ROOT_URLCONF = 'instance.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': (os.path.join(PROJECT_ROOT, 'templates'),), - # 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': ( - "django.contrib.auth.context_processors.auth", - "django.template.context_processors.debug", - "django.template.context_processors.i18n", - "django.template.context_processors.media", - "django.template.context_processors.request", - "django.template.context_processors.static", - "django.template.context_processors.tz", - "django.contrib.messages.context_processors.messages", - - 'wagtail.contrib.settings.context_processors.settings', - ), - 'builtins': [ - 'overextends.templatetags.overextends_tags' - ], - 'loaders': ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - ), - }, - }, -] - - -WSGI_APPLICATION = 'instance.wsgi.application' - -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'handlers': { - 'console': { - 'class': 'logging.StreamHandler', - }, - }, - 'loggers': { - 'aircox.core': { - 'handlers': ['console'], - 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), - }, - 'aircox.test': { - 'handlers': ['console'], - 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), - }, - 'aircox.tools': { - 'handlers': ['console'], - 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), - }, - }, -} - - -# Wagtail -WAGTAIL_SITE_NAME = 'Aircox' - - diff --git a/instance/sample_settings.py b/instance/sample_settings.py index 66b505c..d21759d 100755 --- a/instance/sample_settings.py +++ b/instance/sample_settings.py @@ -1,41 +1,63 @@ """ Sample file for the settings.py -Environment variables: +First part of the file is where you should put your hand, second part is +just basic django initialization. + + +Some variable retrieve environnement variable if they are defined: * AIRCOX_DEBUG: enable/disable debugging - * TZ: [in base_settings] timezone (default: 'Europe/Brussels') - * LANG: [in base_settings] language code + * TZ: timezone (default: 'Europe/Brussels') + * LANG: language code Note that: - SECRET_KEY - ALLOWED_HOSTS - DATABASES - are not defined in base_settings and must be defined here. + are not defined in sample_settings and must be defined here. -You can also take a look at `base_settings` for more information. +You can also configure specific Aircox & Aircox CMS settings. For more +information, please report to these application's settings.py +For Django settings see: + https://docs.djangoproject.com/en/1.8/topics/settings/ + https://docs.djangoproject.com/en/1.8/ref/settings/ """ -import pytz import os -# If Aircox is not installed as a regular python module, you can use: -# import sys -# sys.path.append('/path/to/aircox_parent_folder/') +import sys +import pytz from django.utils import timezone -from .base_settings import * +sys.path.insert(1, os.path.dirname(os.path.realpath(__file__))) + +PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__)) +STATIC_URL = '/static/' +MEDIA_URL = '/media/' +SITE_MEDIA_URL = '/media/' +STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') +MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media') -# define TIME_ZONE before the call to timezone.activate +######################################################################## +# +# You can configure starting from here +# +######################################################################## + +# set current language code. e.g. 'fr_BE' +LANGUAGE_CODE = os.environ.get('LANG') or 'en_US' +# set current timezone. e.g. 'Europe/Brussels' TIME_ZONE = os.environ.get('TZ') or 'UTC' -timezone.activate(pytz.timezone(TIME_ZONE)) +# wagtail site name +WAGTAIL_SITE_NAME = 'Aircox' -# debug or production mode -DEBUG = False -if 'AIRCOX_DEBUG' in os.environ: - DEBUG = (os.environ['AIRCOX_DEBUG'].lower()) in ('true','1') +# debug mode +DEBUG = (os.environ['AIRCOX_DEBUG'].lower() in ('true', 1)) \ + if 'AIRCOX_DEBUG' in os.environ else \ + False if DEBUG: from .dev import * @@ -59,9 +81,145 @@ else: }, } -ALLOWED_HOSTS = ['127.0.0.1:8042'] +# allowed hosts +ALLOWED_HOSTS = ['127.0.0.1:8000'] + +# secret key: you MUST put a consistent secret key SECRET_KEY = '' -WAGTAIL_SITE_NAME='Aircox' + +######################################################################## +# +# You don't really need to configure what is happening below +# +######################################################################## +# Internationalization and timezone +USE_I18N = True +USE_L10N = True +USE_TZ = True + +timezone.activate(pytz.timezone(TIME_ZONE)) + +try: + import locale + locale.setlocale(locale.LC_ALL, LANGUAGE_CODE) +except: + print( + 'Can not set locale {LC}. Is it available on you system? Hint: ' + 'Check /etc/locale.gen and rerun locale-gen as sudo if needed.' + .format(LC = LANGUAGE_CODE) + ) + pass + + + +# Application definition +INSTALLED_APPS = ( + 'aircox', + 'aircox_cms', + + 'jet', + 'wagtail.wagtailforms', + 'wagtail.wagtailredirects', + 'wagtail.wagtailembeds', + 'wagtail.wagtailsites', + 'wagtail.wagtailusers', + 'wagtail.wagtailsnippets', + 'wagtail.wagtaildocs', + 'wagtail.wagtailimages', + 'wagtail.wagtailsearch', + 'wagtail.wagtailadmin', + 'wagtail.wagtailcore', + 'wagtail.contrib.settings', + 'wagtail.contrib.modeladmin', + + 'modelcluster', + 'taggit', + 'honeypot', + + 'django.contrib.contenttypes', + 'django.contrib.auth', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django.contrib.admin', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.gzip.GZipMiddleware', + 'htmlmin.middleware.HtmlMinifyMiddleware', + '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', + 'django.middleware.security.SecurityMiddleware', + + 'wagtail.wagtailcore.middleware.SiteMiddleware', + 'wagtail.wagtailredirects.middleware.RedirectMiddleware', + + 'aircox.middleware.AircoxMiddleware' +) + + +ROOT_URLCONF = 'instance.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': (os.path.join(PROJECT_ROOT, 'templates'),), + # 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': ( + "django.contrib.auth.context_processors.auth", + "django.template.context_processors.debug", + "django.template.context_processors.i18n", + "django.template.context_processors.media", + "django.template.context_processors.request", + "django.template.context_processors.static", + "django.template.context_processors.tz", + "django.contrib.messages.context_processors.messages", + + 'wagtail.contrib.settings.context_processors.settings', + ), + 'builtins': [ + 'overextends.templatetags.overextends_tags' + ], + 'loaders': ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + ), + }, + }, +] + + +WSGI_APPLICATION = 'instance.wsgi.application' + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + }, + }, + 'loggers': { + 'aircox.core': { + 'handlers': ['console'], + 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), + }, + 'aircox.test': { + 'handlers': ['console'], + 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), + }, + 'aircox.tools': { + 'handlers': ['console'], + 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), + }, + }, +}