2014-05-18 20:26:31 +02:00
|
|
|
# -*- python -*-
|
|
|
|
# pymode:lint_ignore=E501
|
2014-05-18 00:07:32 +02:00
|
|
|
"""Common settings and globals."""
|
|
|
|
|
|
|
|
|
2014-05-18 20:26:31 +02:00
|
|
|
from os import environ
|
2014-05-18 00:07:32 +02:00
|
|
|
from os.path import abspath, basename, dirname, join, normpath
|
|
|
|
from sys import path
|
|
|
|
|
2014-05-18 20:26:31 +02:00
|
|
|
# Normally you should not import ANYTHING from Django directly
|
|
|
|
# into your settings, but ImproperlyConfigured is an exception.
|
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
2015-01-17 17:50:59 +01:00
|
|
|
from django.contrib.messages import constants as messages
|
2014-05-18 20:26:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_env_variable(var_name):
|
|
|
|
"""
|
|
|
|
Get a setting from an environment variable.
|
|
|
|
|
|
|
|
:param str var_name: variable name
|
|
|
|
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
return environ[var_name]
|
|
|
|
except KeyError:
|
|
|
|
error_msg = "Set the %s environment variable" % var_name
|
|
|
|
raise ImproperlyConfigured(error_msg)
|
|
|
|
|
2014-05-18 00:07:32 +02:00
|
|
|
|
|
|
|
########## PATH CONFIGURATION
|
|
|
|
# Absolute filesystem path to the Django project directory:
|
|
|
|
DJANGO_ROOT = dirname(dirname(abspath(__file__)))
|
|
|
|
|
|
|
|
# Absolute filesystem path to the top-level project folder:
|
|
|
|
SITE_ROOT = dirname(DJANGO_ROOT)
|
|
|
|
|
|
|
|
# Site name:
|
|
|
|
SITE_NAME = basename(DJANGO_ROOT)
|
|
|
|
|
|
|
|
# Add our project to our pythonpath, this way we don't need to type our project
|
|
|
|
# name in our dotted import paths:
|
|
|
|
path.append(DJANGO_ROOT)
|
|
|
|
########## END PATH CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## DEBUG CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
|
|
|
DEBUG = False
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
|
|
|
|
TEMPLATE_DEBUG = DEBUG
|
|
|
|
########## END DEBUG CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## MANAGER CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
|
|
|
|
ADMINS = (
|
2014-05-18 20:26:31 +02:00
|
|
|
(get_env_variable('GVA_ADMIN_NAME'), get_env_variable('GVA_ADMIN_EMAIL')),
|
2014-05-18 00:07:32 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
|
|
|
|
MANAGERS = ADMINS
|
|
|
|
########## END MANAGER CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## DATABASE CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
2014-05-18 20:26:31 +02:00
|
|
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
|
|
'NAME': get_env_variable('GVA_PGSQL_DATABASE'),
|
|
|
|
'USER': get_env_variable('GVA_PGSQL_USER'),
|
|
|
|
'PASSWORD': get_env_variable('GVA_PGSQL_PASSWORD'),
|
|
|
|
'HOST': get_env_variable('GVA_PGSQL_HOSTNAME'),
|
|
|
|
'PORT': get_env_variable('GVA_PGSQL_PORT'),
|
2014-05-18 00:07:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
########## END DATABASE CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## GENERAL CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
|
2014-05-18 20:26:31 +02:00
|
|
|
TIME_ZONE = 'Europe/Berlin'
|
2014-05-18 00:07:32 +02:00
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
|
2015-01-04 17:56:38 +01:00
|
|
|
LANGUAGE_CODE = 'en-us'
|
2014-05-18 00:07:32 +02:00
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
|
|
|
|
SITE_ID = 1
|
2014-05-18 20:26:31 +02:00
|
|
|
SITES_DOMAIN_NAME = get_env_variable('GVA_DOMAIN_NAME')
|
|
|
|
SITES_SITE_NAME = get_env_variable('GVA_SITE_NAME')
|
2014-05-18 00:07:32 +02:00
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
|
|
|
|
USE_L10N = True
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
|
|
|
|
USE_TZ = True
|
|
|
|
########## END GENERAL CONFIGURATION
|
|
|
|
|
|
|
|
|
2015-01-17 16:06:25 +01:00
|
|
|
LOCALE_PATHS = (
|
|
|
|
normpath(join(SITE_ROOT, 'locale')),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2014-05-18 00:07:32 +02:00
|
|
|
########## MEDIA CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
|
|
|
|
MEDIA_ROOT = normpath(join(SITE_ROOT, 'media'))
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
|
|
|
|
MEDIA_URL = '/media/'
|
|
|
|
########## END MEDIA CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## STATIC FILE CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
|
|
|
|
STATIC_ROOT = normpath(join(SITE_ROOT, 'assets'))
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
|
|
|
|
STATICFILES_DIRS = (
|
|
|
|
normpath(join(SITE_ROOT, 'static')),
|
|
|
|
)
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
|
|
|
|
STATICFILES_FINDERS = (
|
|
|
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
|
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
|
|
)
|
|
|
|
########## END STATIC FILE CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## SECRET CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
|
|
|
# Note: This key should only be used for development and testing.
|
2014-05-18 20:26:31 +02:00
|
|
|
SECRET_KEY = get_env_variable('GVA_SITE_SECRET')
|
2014-05-18 00:07:32 +02:00
|
|
|
########## END SECRET CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## SITE CONFIGURATION
|
|
|
|
# Hosts/domain names that are valid for this site
|
|
|
|
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
|
|
|
|
ALLOWED_HOSTS = []
|
|
|
|
########## END SITE CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## FIXTURE CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
|
|
|
|
FIXTURE_DIRS = (
|
|
|
|
normpath(join(SITE_ROOT, 'fixtures')),
|
|
|
|
)
|
|
|
|
########## END FIXTURE CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## TEMPLATE CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
|
|
|
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
|
|
|
'django.contrib.auth.context_processors.auth',
|
|
|
|
'django.core.context_processors.debug',
|
|
|
|
'django.core.context_processors.i18n',
|
|
|
|
'django.core.context_processors.media',
|
|
|
|
'django.core.context_processors.static',
|
|
|
|
'django.core.context_processors.tz',
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
|
|
|
'django.core.context_processors.request',
|
2015-01-17 16:28:19 +01:00
|
|
|
# allauth specific context processors
|
|
|
|
'allauth.account.context_processors.account',
|
|
|
|
'allauth.socialaccount.context_processors.socialaccount',
|
2015-02-01 13:16:45 +01:00
|
|
|
# custom context processors
|
|
|
|
'gnuviechadmin.context_processors.navigation',
|
2015-02-01 22:15:40 +01:00
|
|
|
'gnuviechadmin.context_processors.version_info',
|
2014-05-18 00:07:32 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
|
|
|
|
TEMPLATE_LOADERS = (
|
|
|
|
'django.template.loaders.filesystem.Loader',
|
|
|
|
'django.template.loaders.app_directories.Loader',
|
|
|
|
)
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
|
|
|
|
TEMPLATE_DIRS = (
|
|
|
|
normpath(join(SITE_ROOT, 'templates')),
|
|
|
|
)
|
|
|
|
########## END TEMPLATE CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## MIDDLEWARE CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#middleware-classes
|
|
|
|
MIDDLEWARE_CLASSES = (
|
|
|
|
# Default Django middleware.
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
2014-05-18 20:26:31 +02:00
|
|
|
# uncomment next line to enable translation to browser locale
|
|
|
|
'django.middleware.locale.LocaleMiddleware',
|
2014-05-18 00:07:32 +02:00
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
|
|
)
|
|
|
|
########## END MIDDLEWARE CONFIGURATION
|
|
|
|
|
|
|
|
|
2015-01-17 16:28:19 +01:00
|
|
|
AUTHENTICATION_BACKENDS = (
|
|
|
|
# Needed to login by username in Django admin, regardless of `allauth`
|
|
|
|
"django.contrib.auth.backends.ModelBackend",
|
|
|
|
|
|
|
|
# `allauth` specific authentication methods, such as login by e-mail
|
|
|
|
"allauth.account.auth_backends.AuthenticationBackend",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2014-05-18 00:07:32 +02:00
|
|
|
########## URL CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
|
|
|
|
ROOT_URLCONF = '%s.urls' % SITE_NAME
|
|
|
|
########## END URL CONFIGURATION
|
|
|
|
|
|
|
|
|
2014-12-17 21:22:37 +01:00
|
|
|
########## TEST RUNNER CONFIGURATION
|
|
|
|
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|
|
|
########## END TEST RUNNER CONFIGURATION
|
|
|
|
|
|
|
|
|
2014-05-18 00:07:32 +02:00
|
|
|
########## APP CONFIGURATION
|
|
|
|
DJANGO_APPS = (
|
|
|
|
# Default Django apps:
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.sites',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
|
|
|
|
|
|
|
# Useful template tags:
|
2014-05-18 20:26:31 +02:00
|
|
|
'django.contrib.humanize',
|
2014-05-18 00:07:32 +02:00
|
|
|
|
|
|
|
# Admin panel and documentation:
|
|
|
|
'django.contrib.admin',
|
2015-02-01 16:34:46 +01:00
|
|
|
|
|
|
|
# Flatpages for about page
|
|
|
|
'django.contrib.flatpages',
|
2015-01-17 13:58:54 +01:00
|
|
|
|
|
|
|
'crispy_forms',
|
2014-05-18 00:07:32 +02:00
|
|
|
)
|
|
|
|
|
2015-01-17 16:28:19 +01:00
|
|
|
ALLAUTH_APPS = (
|
|
|
|
'allauth',
|
|
|
|
'allauth.account',
|
|
|
|
'allauth.socialaccount',
|
|
|
|
'allauth.socialaccount.providers.google',
|
|
|
|
'allauth.socialaccount.providers.linkedin_oauth2',
|
|
|
|
'allauth.socialaccount.providers.twitter',
|
|
|
|
'allauth.socialaccount.providers.xing',
|
|
|
|
)
|
|
|
|
|
2014-05-18 00:07:32 +02:00
|
|
|
# Apps specific for this project go here.
|
|
|
|
LOCAL_APPS = (
|
2015-01-17 14:01:22 +01:00
|
|
|
'dashboard',
|
2014-12-29 15:55:57 +01:00
|
|
|
'taskresults',
|
2015-10-12 00:23:31 +02:00
|
|
|
'ldaptasks',
|
2015-01-04 18:06:44 +01:00
|
|
|
'mysqltasks',
|
|
|
|
'pgsqltasks',
|
2015-01-26 20:58:43 +01:00
|
|
|
'fileservertasks',
|
|
|
|
'webtasks',
|
2014-05-25 14:53:58 +02:00
|
|
|
'domains',
|
2014-05-24 21:28:33 +02:00
|
|
|
'osusers',
|
2014-05-18 20:26:31 +02:00
|
|
|
'managemails',
|
2015-01-04 17:57:51 +01:00
|
|
|
'userdbs',
|
2015-01-18 13:22:31 +01:00
|
|
|
'hostingpackages',
|
2015-01-26 22:47:49 +01:00
|
|
|
'websites',
|
2015-02-01 20:58:53 +01:00
|
|
|
'contact_form',
|
2014-05-18 00:07:32 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
2015-01-17 16:28:19 +01:00
|
|
|
INSTALLED_APPS = DJANGO_APPS + ALLAUTH_APPS + LOCAL_APPS
|
2015-01-17 17:50:59 +01:00
|
|
|
|
|
|
|
MESSAGE_TAGS = {
|
|
|
|
messages.DEBUG: '',
|
2015-01-31 13:12:51 +01:00
|
|
|
messages.ERROR: 'alert-danger',
|
|
|
|
messages.INFO: 'alert-info',
|
|
|
|
messages.SUCCESS: 'alert-success',
|
|
|
|
messages.WARNING: 'alert-warning',
|
2015-01-17 17:50:59 +01:00
|
|
|
}
|
2014-05-18 00:07:32 +02:00
|
|
|
########## END APP CONFIGURATION
|
|
|
|
|
|
|
|
|
2015-01-17 17:50:59 +01:00
|
|
|
########## ALLAUTH CONFIGURATION
|
2015-01-18 00:38:33 +01:00
|
|
|
ACCOUNT_EMAIL_REQUIRED = True
|
|
|
|
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
2015-01-17 17:50:59 +01:00
|
|
|
LOGIN_REDIRECT_URL = '/'
|
|
|
|
SOCIALACCOUNT_QUERY_EMAIL = True
|
|
|
|
########## END ALLAUTH CONFIGURATION
|
|
|
|
|
|
|
|
|
2015-01-17 13:58:54 +01:00
|
|
|
########## CRISPY FORMS CONFIGURATION
|
|
|
|
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
|
|
########## END CRISPY_FORMS CONFIGURATION
|
|
|
|
|
|
|
|
|
2014-05-18 00:07:32 +02:00
|
|
|
########## LOGGING CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
|
|
|
# A sample logging configuration. The only tangible logging
|
|
|
|
# performed by this configuration is to send an email to
|
|
|
|
# the site admins on every HTTP 500 error when DEBUG=False.
|
|
|
|
# See http://docs.djangoproject.com/en/dev/topics/logging for
|
|
|
|
# more details on how to customize your logging configuration.
|
|
|
|
LOGGING = {
|
|
|
|
'version': 1,
|
|
|
|
'disable_existing_loggers': False,
|
2015-02-01 14:59:36 +01:00
|
|
|
'formatters': {
|
|
|
|
'verbose': {
|
|
|
|
'format': '%(levelname)s %(asctime)s %(name)s '
|
|
|
|
'%(module)s:%(lineno)d %(process)d %(thread)d %(message)s',
|
|
|
|
},
|
|
|
|
'simple': {
|
|
|
|
'format': '%(levelname)s %(name)s:%(lineno)d %(message)s',
|
|
|
|
},
|
|
|
|
},
|
2014-05-18 00:07:32 +02:00
|
|
|
'filters': {
|
|
|
|
'require_debug_false': {
|
|
|
|
'()': 'django.utils.log.RequireDebugFalse'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'handlers': {
|
|
|
|
'mail_admins': {
|
|
|
|
'level': 'ERROR',
|
|
|
|
'filters': ['require_debug_false'],
|
|
|
|
'class': 'django.utils.log.AdminEmailHandler'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'loggers': {
|
|
|
|
'django.request': {
|
|
|
|
'handlers': ['mail_admins'],
|
|
|
|
'level': 'ERROR',
|
|
|
|
'propagate': True,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
########## END LOGGING CONFIGURATION
|
|
|
|
|
|
|
|
|
|
|
|
########## WSGI CONFIGURATION
|
|
|
|
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
|
|
|
|
WSGI_APPLICATION = '%s.wsgi.application' % SITE_NAME
|
|
|
|
########## END WSGI CONFIGURATION
|
|
|
|
|
|
|
|
|
2014-05-25 23:35:06 +02:00
|
|
|
########## CELERY CONFIGURATION
|
|
|
|
BROKER_URL = get_env_variable('GVA_BROKER_URL')
|
|
|
|
CELERY_RESULT_BACKEND = 'amqp'
|
|
|
|
CELERY_RESULT_PERSISTENT = True
|
|
|
|
CELERY_TASK_RESULT_EXPIRES = None
|
2014-05-30 17:10:22 +02:00
|
|
|
CELERY_ROUTES = (
|
2015-01-01 22:35:55 +01:00
|
|
|
'gvacommon.celeryrouters.GvaRouter',
|
2014-05-30 17:10:22 +02:00
|
|
|
)
|
2014-12-29 12:57:02 +01:00
|
|
|
CELERY_TIMEZONE = 'Europe/Berlin'
|
|
|
|
CELERY_ENABLE_UTC = True
|
|
|
|
CELERY_ACCEPT_CONTENT = ['json']
|
2014-12-26 15:10:36 +01:00
|
|
|
CELERY_TASK_SERIALIZER = 'json'
|
|
|
|
CELERY_RESULT_SERIALIZER = 'json'
|
2014-05-25 23:35:06 +02:00
|
|
|
########## END CELERY CONFIGURATION
|
|
|
|
|
|
|
|
|
2014-05-25 00:55:02 +02:00
|
|
|
########## CUSTOM APP CONFIGURATION
|
|
|
|
OSUSER_MINUID = int(get_env_variable('GVA_MIN_OS_UID'))
|
|
|
|
OSUSER_MINGID = int(get_env_variable('GVA_MIN_OS_GID'))
|
|
|
|
OSUSER_USERNAME_PREFIX = get_env_variable('GVA_OSUSER_PREFIX')
|
|
|
|
OSUSER_HOME_BASEPATH = get_env_variable('GVA_OSUSER_HOME_BASEPATH')
|
|
|
|
OSUSER_DEFAULT_SHELL = get_env_variable('GVA_OSUSER_DEFAULT_SHELL')
|
2015-01-24 16:17:39 +01:00
|
|
|
OSUSER_SFTP_GROUP = 'sftponly'
|
|
|
|
OSUSER_SSH_GROUP = 'sshusers'
|
|
|
|
OSUSER_DEFAULT_GROUPS = [OSUSER_SFTP_GROUP]
|
|
|
|
OSUSER_UPLOAD_SERVER = get_env_variable('GVA_OSUSER_UPLOADSERVER')
|
2015-02-01 13:16:45 +01:00
|
|
|
|
|
|
|
GVA_LINK_WEBMAIL = get_env_variable('GVA_WEBMAIL_URL')
|
|
|
|
GVA_LINK_PHPMYADMIN = get_env_variable('GVA_PHPMYADMIN_URL')
|
|
|
|
GVA_LINK_PHPPGADMIN = get_env_variable('GVA_PHPPGADMIN_URL')
|
2014-05-25 00:55:02 +02:00
|
|
|
########## END CUSTOM APP CONFIGURATION
|