424 lines
13 KiB
Django/Jinja
424 lines
13 KiB
Django/Jinja
"""
|
|
Django Settings for Mailman Suite (hyperkitty + postorius)
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/1.8/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/1.8/ref/settings/
|
|
"""
|
|
import os
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = False
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = 'very_very_secret'
|
|
|
|
ADMINS = (
|
|
('Mailman Suite Admin', 'root@localhost'),
|
|
)
|
|
|
|
SITE_ID = 1
|
|
|
|
# Hosts/domain names that are valid for this site; required if DEBUG is False
|
|
# See https://docs.djangoproject.com/en/1.8/ref/settings/#allowed-hosts
|
|
# Set to '*' per default in the Deian package to allow all hostnames. Mailman3
|
|
# is meant to run behind a webserver reverse proxy anyway.
|
|
ALLOWED_HOSTS = [
|
|
#"localhost", # Archiving API from Mailman, keep it.
|
|
# "lists.your-domain.org",
|
|
# Add here all production URLs you may have.
|
|
'*'
|
|
]
|
|
|
|
# Mailman API credentials
|
|
MAILMAN_REST_API_URL = 'http://localhost:8001'
|
|
MAILMAN_REST_API_USER = 'restadmin'
|
|
MAILMAN_REST_API_PASS = 'mailman3'
|
|
MAILMAN_ARCHIVER_KEY = 'mailman3'
|
|
MAILMAN_ARCHIVER_FROM = (
|
|
'127.0.0.1',
|
|
'::1',
|
|
# IP addresses for this machine
|
|
'{{ mail_ipv4_addr }}',
|
|
)
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = (
|
|
'hyperkitty',
|
|
'postorius',
|
|
'django_mailman3',
|
|
# Uncomment the next line to enable the admin:
|
|
'django.contrib.admin',
|
|
# Uncomment the next line to enable admin documentation:
|
|
# 'django.contrib.admindocs',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.sites',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'rest_framework',
|
|
'django_gravatar',
|
|
'compressor',
|
|
'haystack',
|
|
'django_extensions',
|
|
'django_q',
|
|
'allauth',
|
|
'allauth.account',
|
|
'allauth.socialaccount',
|
|
#'django_mailman3.lib.auth.fedora',
|
|
#'allauth.socialaccount.providers.openid',
|
|
#'allauth.socialaccount.providers.github',
|
|
#'allauth.socialaccount.providers.gitlab',
|
|
#'allauth.socialaccount.providers.google',
|
|
#'allauth.socialaccount.providers.facebook',
|
|
#'allauth.socialaccount.providers.twitter',
|
|
#'allauth.socialaccount.providers.stackexchange',
|
|
)
|
|
|
|
MIDDLEWARE = (
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.middleware.locale.LocaleMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'django_mailman3.middleware.TimezoneMiddleware',
|
|
'postorius.middleware.PostoriusMiddleware',
|
|
)
|
|
|
|
ROOT_URLCONF = 'urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [],
|
|
'APP_DIRS': True,
|
|
'OPTIONS': {
|
|
'context_processors': [
|
|
'django.template.context_processors.debug',
|
|
'django.template.context_processors.i18n',
|
|
'django.template.context_processors.media',
|
|
'django.template.context_processors.static',
|
|
'django.template.context_processors.tz',
|
|
'django.template.context_processors.csrf',
|
|
'django.template.context_processors.request',
|
|
'django.contrib.auth.context_processors.auth',
|
|
'django.contrib.messages.context_processors.messages',
|
|
'django_mailman3.context_processors.common',
|
|
'hyperkitty.context_processors.common',
|
|
'postorius.context_processors.postorius',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = 'wsgi.application'
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
# Use 'sqlite3', 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
|
#'ENGINE': 'django.db.backends.sqlite3',
|
|
#'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
'ENGINE': 'django.db.backends.mysql',
|
|
# DB name or path to database file if using sqlite3.
|
|
'NAME': 'mailman3web',
|
|
# The following settings are not used with sqlite3:
|
|
'USER': 'mailman3web',
|
|
'PASSWORD': 'mailman3web',
|
|
# HOST: empty for localhost through domain sockets or '127.0.0.1' for
|
|
# localhost through TCP.
|
|
'HOST': 'coffee',
|
|
# PORT: set to empty string for default.
|
|
'PORT': '',
|
|
# OPTIONS: Extra parameters to use when connecting to the database.
|
|
'OPTIONS': {
|
|
# Set sql_mode to 'STRICT_TRANS_TABLES' for MySQL. See
|
|
# https://docs.djangoproject.com/en/1.11/ref/
|
|
# databases/#setting-sql-mode
|
|
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
|
|
'charset': 'utf8mb4',
|
|
},
|
|
}
|
|
}
|
|
|
|
# Full-text search engine
|
|
HAYSTACK_CONNECTIONS = {
|
|
'default': {
|
|
'ENGINE': 'xapian_backend.XapianEngine',
|
|
'PATH': '/opt/mailman3/web/xapian_index',
|
|
}
|
|
}
|
|
|
|
# Django Q
|
|
Q_CLUSTER = {
|
|
'timeout': 300,
|
|
'retry': 305,
|
|
'save_limit': 100,
|
|
'orm': 'default',
|
|
'poll': 5,
|
|
'workers': 2,
|
|
}
|
|
|
|
# Cache
|
|
CACHES = {
|
|
'default': {
|
|
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
|
|
'LOCATION': '127.0.0.1:11211',
|
|
}
|
|
}
|
|
|
|
# If you're behind a proxy, use the X-Forwarded-Host header
|
|
# See https://docs.djangoproject.com/en/1.8/ref/settings/#use-x-forwarded-host
|
|
USE_X_FORWARDED_HOST = True
|
|
|
|
# And if your proxy does your SSL encoding for you, set SECURE_PROXY_SSL_HEADER
|
|
# https://docs.djangoproject.com/en/1.8/ref/settings/#secure-proxy-ssl-header
|
|
# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
|
# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_SCHEME', 'https')
|
|
|
|
# Other security settings
|
|
# SECURE_SSL_REDIRECT = True
|
|
# If you set SECURE_SSL_REDIRECT to True, make sure the SECURE_REDIRECT_EXEMPT
|
|
# contains at least this line:
|
|
# SECURE_REDIRECT_EXEMPT = [
|
|
# "archives/api/mailman/.*", # Request from Mailman.
|
|
# ]
|
|
# SESSION_COOKIE_SECURE = True
|
|
# SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
# SECURE_BROWSER_XSS_FILTER = True
|
|
# CSRF_COOKIE_SECURE = True
|
|
# CSRF_COOKIE_HTTPONLY = True
|
|
# X_FRAME_OPTIONS = 'DENY'
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
{
|
|
'NAME':
|
|
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
},
|
|
{
|
|
'NAME':
|
|
'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
},
|
|
{
|
|
'NAME':
|
|
'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
},
|
|
{
|
|
'NAME':
|
|
'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
},
|
|
]
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
TIME_ZONE = 'America/Toronto'
|
|
|
|
USE_I18N = True
|
|
USE_L10N = True
|
|
USE_TZ = True
|
|
|
|
# Django 1.6+ defaults to a JSON serializer, but it won't work with
|
|
# django-openid, see
|
|
# https://bugs.launchpad.net/django-openid-auth/+bug/1252826
|
|
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
|
|
|
|
LOGIN_URL = 'account_login'
|
|
LOGIN_REDIRECT_URL = 'list_index'
|
|
LOGOUT_URL = 'account_logout'
|
|
|
|
# List of finder classes that know how to find static files in
|
|
# various locations.
|
|
STATICFILES_FINDERS = (
|
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
|
'compressor.finders.CompressorFinder',
|
|
)
|
|
|
|
STATIC_ROOT = '/opt/mailman3/web/static'
|
|
STATIC_URL = '/static/'
|
|
HOSTNAME = 'mailman.{{ base_domain }}'
|
|
# Set default domain for email addresses.
|
|
EMAILNAME = '{{ base_domain }}'
|
|
|
|
# If you enable internal authentication, this is the address that the emails
|
|
# will appear to be coming from. Make sure you set a valid domain name,
|
|
# otherwise the emails may get rejected.
|
|
# https://docs.djangoproject.com/en/1.8/ref/settings/#default-from-email
|
|
# DEFAULT_FROM_EMAIL = "mailing-lists@you-domain.org"
|
|
DEFAULT_FROM_EMAIL = 'postorius@{}'.format(EMAILNAME)
|
|
|
|
# If you enable email reporting for error messages, this is where those emails
|
|
# will appear to be coming from. Make sure you set a valid domain name,
|
|
# otherwise the emails may get rejected.
|
|
# https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-SERVER_EMAIL
|
|
# SERVER_EMAIL = 'root@your-domain.org'
|
|
SERVER_EMAIL = 'root@{}'.format(EMAILNAME)
|
|
|
|
# Change this when you have a real email backend
|
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
|
|
|
# Compatibility with Bootstrap 3
|
|
from django.contrib.messages import constants as messages # flake8: noqa
|
|
MESSAGE_TAGS = {
|
|
messages.ERROR: 'danger'
|
|
}
|
|
|
|
|
|
#
|
|
# Social auth
|
|
#
|
|
AUTHENTICATION_BACKENDS = (
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
'allauth.account.auth_backends.AuthenticationBackend',
|
|
)
|
|
|
|
# Django Allauth
|
|
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
|
|
# setting this to False causes the createsuperuser command to fail
|
|
ACCOUNT_EMAIL_REQUIRED = True
|
|
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
|
|
# You probably want https in production, but this is a dev setup file
|
|
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "http"
|
|
ACCOUNT_UNIQUE_EMAIL = True
|
|
|
|
SOCIALACCOUNT_PROVIDERS = {
|
|
#'openid': {
|
|
# 'SERVERS': [
|
|
# dict(id='yahoo',
|
|
# name='Yahoo',
|
|
# openid_url='http://me.yahoo.com'),
|
|
# ],
|
|
#},
|
|
#'google': {
|
|
# 'SCOPE': ['profile', 'email'],
|
|
# 'AUTH_PARAMS': {'access_type': 'online'},
|
|
#},
|
|
#'facebook': {
|
|
# 'METHOD': 'oauth2',
|
|
# 'SCOPE': ['email'],
|
|
# 'FIELDS': [
|
|
# 'email',
|
|
# 'name',
|
|
# 'first_name',
|
|
# 'last_name',
|
|
# 'locale',
|
|
# 'timezone',
|
|
# ],
|
|
# 'VERSION': 'v2.4',
|
|
#},
|
|
}
|
|
|
|
#
|
|
# Gravatar
|
|
# https://github.com/twaddington/django-gravatar
|
|
#
|
|
# Gravatar base url.
|
|
# GRAVATAR_URL = 'http://cdn.libravatar.org/'
|
|
# Gravatar base secure https url.
|
|
# GRAVATAR_SECURE_URL = 'https://seccdn.libravatar.org/'
|
|
# Gravatar size in pixels.
|
|
# GRAVATAR_DEFAULT_SIZE = '80'
|
|
# An image url or one of the following: 'mm', 'identicon', 'monsterid',
|
|
# 'wavatar', 'retro'.
|
|
# GRAVATAR_DEFAULT_IMAGE = 'mm'
|
|
# One of the following: 'g', 'pg', 'r', 'x'.
|
|
# GRAVATAR_DEFAULT_RATING = 'g'
|
|
# True to use https by default, False for plain http.
|
|
# GRAVATAR_DEFAULT_SECURE = True
|
|
|
|
#
|
|
# django-compressor
|
|
# https://pypi.python.org/pypi/django_compressor
|
|
#
|
|
COMPRESS_PRECOMPILERS = (
|
|
('text/less', 'lessc {infile} {outfile}'),
|
|
('text/x-scss', 'sassc -t compressed {infile} {outfile}'),
|
|
('text/x-sass', 'sassc -t compressed {infile} {outfile}'),
|
|
)
|
|
|
|
# On a production setup, setting COMPRESS_OFFLINE to True will bring a
|
|
# significant performance improvement, as CSS files will not need to be
|
|
# recompiled on each requests. It means running an additional "compress"
|
|
# management command after each code upgrade.
|
|
# http://django-compressor.readthedocs.io/en/latest/usage/#offline-compression
|
|
COMPRESS_OFFLINE = True
|
|
|
|
POSTORIUS_TEMPLATE_BASE_URL = 'http://mailman.{{ base_domain }}/'
|
|
|
|
# Custom logging. Disable sending log emails because this floods our inbox.
|
|
# See https://lincolnloop.com/blog/disabling-error-emails-django/.
|
|
LOGGING = {
|
|
'version': 1,
|
|
'disable_existing_loggers': False,
|
|
'filters': {
|
|
'require_debug_false': {
|
|
'()': 'django.utils.log.RequireDebugFalse'
|
|
}
|
|
},
|
|
'handlers': {
|
|
'console': {
|
|
'class': 'logging.StreamHandler',
|
|
'formatter': 'simple',
|
|
},
|
|
},
|
|
'loggers': {
|
|
'django.request': {
|
|
'handlers': ['console'],
|
|
'level': 'WARNING',
|
|
'propagate': True,
|
|
},
|
|
'django': {
|
|
'handlers': ['console'],
|
|
'level': 'WARNING',
|
|
'propagate': True,
|
|
},
|
|
'hyperkitty': {
|
|
'handlers': ['console'],
|
|
'level': 'WARNING',
|
|
'propagate': True,
|
|
},
|
|
'postorius': {
|
|
'handlers': ['console'],
|
|
'level': 'WARNING',
|
|
'propagate': True,
|
|
},
|
|
},
|
|
'formatters': {
|
|
'verbose': {
|
|
'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s'
|
|
},
|
|
'simple': {
|
|
'format': '%(levelname)s %(message)s'
|
|
},
|
|
},
|
|
#'root': {
|
|
# 'handlers': ['file'],
|
|
# 'level': 'INFO',
|
|
#},
|
|
}
|
|
|
|
#
|
|
# HyperKitty-specific
|
|
#
|
|
|
|
# Only display mailing-lists from the same virtual host as the webserver
|
|
FILTER_VHOST = False
|