From 92963a0f4cda46e6e21f4c82159aa0f8d7b9e8cd Mon Sep 17 00:00:00 2001 From: Andrew Fyfe Date: Mon, 18 Dec 2017 14:56:42 +0000 Subject: [PATCH] update test_project files synced with a fresh deployment using django 1.11.8 --- test_project/manage.py | 18 ++- test_project/test_project/__init__.py | 1 - test_project/test_project/settings.py | 207 ++++++++++++++++---------- test_project/test_project/urls.py | 2 +- test_project/test_project/wsgi.py | 6 +- 5 files changed, 149 insertions(+), 85 deletions(-) diff --git a/test_project/manage.py b/test_project/manage.py index 7fae8c557..ba4bba75c 100755 --- a/test_project/manage.py +++ b/test_project/manage.py @@ -7,7 +7,19 @@ import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings") - - from django.core.management import execute_from_command_line - + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django # noqa + except ImportError: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) + raise execute_from_command_line(sys.argv) diff --git a/test_project/test_project/__init__.py b/test_project/test_project/__init__.py index baffc4882..e69de29bb 100644 --- a/test_project/test_project/__init__.py +++ b/test_project/test_project/__init__.py @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/test_project/test_project/settings.py b/test_project/test_project/settings.py index 0cf7bdcde..3f9d0dcda 100644 --- a/test_project/test_project/settings.py +++ b/test_project/test_project/settings.py @@ -1,26 +1,29 @@ """ Django settings for test_project project. +Generated by 'django-admin startproject' using Django 1.11.8. + For more information on this file, see -https://docs.djangoproject.com/en/1.6/topics/settings/ +https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.6/ref/settings/ +https://docs.djangoproject.com/en/1.11/ref/settings/ """ from __future__ import unicode_literals -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -import os from logging.handlers import SysLogHandler +import os -from modoboa.test_settings import * # NOQA +from modoboa.test_settings import * # noqa -BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.realpath(os.path.dirname(os.path.dirname(__file__))) # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '!8o(-dbbl3e+*bh7nx-^xysdt)1gso*%@4ze4-9_9o+i&t--u_' @@ -37,6 +40,10 @@ ALLOWED_HOSTS = [ SITE_ID = 1 +# Security settings + +X_FRAME_OPTIONS = "SAMEORIGIN" + # Application definition INSTALLED_APPS = ( @@ -47,8 +54,10 @@ INSTALLED_APPS = ( 'django.contrib.sites', 'django.contrib.staticfiles', 'reversion', + 'ckeditor', + 'ckeditor_uploader', 'rest_framework', - 'rest_framework.authtoken' + 'rest_framework.authtoken', ) # A dedicated place to register Modoboa applications @@ -59,10 +68,11 @@ MODOBOA_APPS = ( 'modoboa.core', 'modoboa.lib', 'modoboa.admin', - 'modoboa.limits', 'modoboa.transport', 'modoboa.relaydomains', + 'modoboa.limits', 'modoboa.parameters', + # Modoboa extensions here. ) INSTALLED_APPS += MODOBOA_APPS @@ -85,10 +95,88 @@ MIDDLEWARE = ( ) AUTHENTICATION_BACKENDS = ( + # 'modoboa.lib.authbackends.LDAPBackend', + # 'modoboa.lib.authbackends.SMTPBackend', 'django.contrib.auth.backends.ModelBackend', ) -# Password validation rules +# SMTP authentication +# AUTH_SMTP_SERVER_ADDRESS = 'localhost' +# AUTH_SMTP_SERVER_PORT = 25 +# AUTH_SMTP_SECURED_MODE = None # 'ssl' or 'starttls' are accepted + + +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.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + 'modoboa.core.context_processors.top_notifications', + ], + 'debug': TEMPLATE_DEBUG, + }, + }, +] + +ROOT_URLCONF = 'test_project.urls' + +WSGI_APPLICATION = 'test_project.wsgi.application' + + +# Internationalization +# https://docs.djangoproject.com/en/1.11/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.11/howto/static-files/ + +STATIC_URL = '/sitestatic/' +STATIC_ROOT = os.path.join(BASE_DIR, 'sitestatic') +STATICFILES_DIRS = ( + os.path.join(BASE_DIR, '..', 'modoboa', 'bower_components'), +) + +MEDIA_URL = '/media/' +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') + +# Rest framework settings + +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.TokenAuthentication', + 'rest_framework.authentication.SessionAuthentication', + ), +} + +# Modoboa settings +# MODOBOA_CUSTOM_LOGO = os.path.join(MEDIA_URL, "custom_logo.png") + +# DOVECOT_LOOKUP_PATH = ('/path/to/dovecot', ) + +MODOBOA_API_URL = 'https://api.modoboa.org/1/' + +# Password validation +# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators + AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', @@ -113,77 +201,38 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] -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.template.context_processors.i18n', - 'django.template.context_processors.media', - 'django.template.context_processors.static', - 'django.template.context_processors.tz', - 'django.contrib.messages.context_processors.messages', - 'modoboa.core.context_processors.top_notifications', - ], - 'debug': False, - }, +# CKeditor + +CKEDITOR_UPLOAD_PATH = "uploads/" + +CKEDITOR_IMAGE_BACKEND = "pillow" + +CKEDITOR_RESTRICT_BY_USER = True + +CKEDITOR_BROWSE_SHOW_DIRS = True + +CKEDITOR_ALLOW_NONIMAGE_FILES = False + +CKEDITOR_CONFIGS = { + 'default': { + 'allowedContent': True, + 'toolbar': 'Modoboa', + 'width': None, + 'toolbar_Modoboa': [ + ['Bold', 'Italic', 'Underline'], + ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], + ['BidiLtr', 'BidiRtl', 'Language'], + ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent'], + ['Undo', 'Redo'], + ['Link', 'Unlink', 'Anchor', '-', 'Smiley'], + ['TextColor', 'BGColor', '-', 'Source'], + ['Font', 'FontSize'], + ['Image', ], + ['SpellChecker'] + ], }, -] - -ROOT_URLCONF = 'test_project.urls' - -WSGI_APPLICATION = 'test_project.wsgi.application' - - -# Internationalization -# https://docs.djangoproject.com/en/1.6/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'UTC' - -USE_I18N = True - -USE_L10N = False - -USE_TZ = True - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.6/howto/static-files/ - -STATIC_URL = '/sitestatic/' -STATIC_ROOT = os.path.join(BASE_DIR, 'sitestatic') -STATICFILES_DIRS = ( - os.path.join(BASE_DIR, '..', 'modoboa', 'bower_components'), -) - -MEDIA_URL = '/media/' -MEDIA_ROOT = os.path.join(BASE_DIR, 'media') - -# Rest framework settings - -REST_FRAMEWORK = { - 'DEFAULT_AUTHENTICATION_CLASSES': ( - 'rest_framework.authentication.TokenAuthentication', - 'rest_framework.authentication.SessionAuthentication', - ), - 'DEFAULT_PERMISSION_CLASSES': ( - 'rest_framework.permissions.IsAuthenticated', - ) } -# Modoboa settings -# MODOBOA_CUSTOM_LOGO = os.path.join(MEDIA_URL, "custom_logo.png") - -# DOVECOT_LOOKUP_PATH = ('/path/to/dovecot', ) - -MODOBOA_API_URL = 'http://api.modoboa.org/1/' - # Logging configuration LOGGING = { @@ -216,3 +265,5 @@ LOGGING = { } } } + +# Load settings from extensions diff --git a/test_project/test_project/urls.py b/test_project/test_project/urls.py index 1317f7c7b..136bd8a16 100644 --- a/test_project/test_project/urls.py +++ b/test_project/test_project/urls.py @@ -3,5 +3,5 @@ from __future__ import unicode_literals from django.conf.urls import include, url urlpatterns = [ - url(r'', include('modoboa.urls')), + url(r"", include("modoboa.urls")), ] diff --git a/test_project/test_project/wsgi.py b/test_project/test_project/wsgi.py index e63b59d9e..fce40e063 100644 --- a/test_project/test_project/wsgi.py +++ b/test_project/test_project/wsgi.py @@ -4,13 +4,15 @@ WSGI config for test_project project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ """ from __future__ import unicode_literals import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings") from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings") + application = get_wsgi_application()