· 7 years ago · Mar 21, 2018, 10:18 PM
1# -*- coding: utf-8 -*-
2# Copyright (C) 1998-2016 by the Free Software Foundation, Inc.
3#
4# This file is part of Mailman Suite.
5#
6# Mailman Suite is free sofware: you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by the Free
8# Software Foundation, either version 3 of the License, or (at your option)
9# any later version.
10#
11# Mailman Suite is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14# for more details.
15
16# You should have received a copy of the GNU General Public License along
17# with Mailman Suite. If not, see <http://www.gnu.org/licenses/>.
18"""
19Django Settings for Mailman Suite (hyperkitty + postorius)
20
21For more information on this file, see
22https://docs.djangoproject.com/en/1.8/topics/settings/
23
24For the full list of settings and their values, see
25https://docs.djangoproject.com/en/1.8/ref/settings/
26"""
27
28# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
29import os
30
31BASE_DIR = os.path.dirname(os.path.abspath(__file__))
32
33# SECURITY WARNING: keep the secret key used in production secret!
34SECRET_KEY = 'fee5Chohmai3AhCohK6ohchoh0eizu'
35
36# SECURITY WARNING: don't run with debug turned on in production!
37DEBUG = False
38
39ADMINS = (
40 # ('FFNW admin', 'admin@ffnw.de'),
41)
42
43SITE_ID = 1
44
45# Hosts/domain names that are valid for this site; required if DEBUG is False
46# See https://docs.djangoproject.com/en/1.8/ref/settings/#allowed-hosts
47ALLOWED_HOSTS = [
48 "localhost", # Archiving API from Mailman, keep it.
49 "lists.ffnw.de",
50 # Add here all production URLs you may have.
51]
52
53# Mailman API credentials
54MAILMAN_REST_API_URL = 'http://localhost:8001'
55MAILMAN_REST_API_USER = 'restadmin'
56MAILMAN_REST_API_PASS = 'aqu0ahlee8ahHah'
57MAILMAN_ARCHIVER_KEY = 'cee6be2ZaiyaFah'
58MAILMAN_ARCHIVER_FROM = ('127.0.0.1', '::1')
59
60# Application definition
61
62INSTALLED_APPS = (
63 'hyperkitty',
64 'postorius',
65 'django_mailman3',
66 # Uncomment the next line to enable the admin:
67 'django.contrib.admin',
68 # Uncomment the next line to enable admin documentation:
69 # 'django.contrib.admindocs',
70 'django.contrib.auth',
71 'django.contrib.contenttypes',
72 'django.contrib.sessions',
73 'django.contrib.sites',
74 'django.contrib.messages',
75 'django.contrib.staticfiles',
76 'rest_framework',
77 'django_gravatar',
78 'paintstore',
79 'compressor',
80 'haystack',
81 'django_extensions',
82 'django_q',
83 'allauth',
84 'allauth.account',
85 'allauth.socialaccount',
86 'django_mailman3.lib.auth.fedora',
87 #'allauth.socialaccount.providers.openid',
88 #'allauth.socialaccount.providers.github',
89 #'allauth.socialaccount.providers.gitlab',
90 #'allauth.socialaccount.providers.google',
91 #'allauth.socialaccount.providers.facebook',
92 #'allauth.socialaccount.providers.twitter',
93 #'allauth.socialaccount.providers.stackexchange',
94)
95
96
97#MIDDLEWARE_CLASSES = (
98# 'django.contrib.sessions.middleware.SessionMiddleware',
99# 'django.middleware.common.CommonMiddleware',
100# 'django.middleware.csrf.CsrfViewMiddleware',
101# 'django.middleware.locale.LocaleMiddleware',
102# 'django.contrib.auth.middleware.AuthenticationMiddleware',
103# 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
104# 'django.contrib.messages.middleware.MessageMiddleware',
105# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
106# 'django.middleware.security.SecurityMiddleware',
107# 'django_mailman3.middleware.TimezoneMiddleware',
108# 'postorius.middleware.PostoriusMiddleware',
109#)
110
111ROOT_URLCONF = 'urls'
112
113
114TEMPLATES = [
115 {
116 'BACKEND': 'django.template.backends.django.DjangoTemplates',
117 'DIRS': [],
118 'APP_DIRS': True,
119 'OPTIONS': {
120 'context_processors': [
121 'django.template.context_processors.debug',
122 'django.template.context_processors.i18n',
123 'django.template.context_processors.media',
124 'django.template.context_processors.static',
125 'django.template.context_processors.tz',
126 'django.template.context_processors.csrf',
127 'django.template.context_processors.request',
128 'django.contrib.auth.context_processors.auth',
129 'django.contrib.messages.context_processors.messages',
130 'django_mailman3.context_processors.common',
131 'hyperkitty.context_processors.common',
132 'postorius.context_processors.postorius',
133 ],
134 },
135 },
136]
137
138WSGI_APPLICATION = 'wsgi.application'
139
140
141# Database
142# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
143
144DATABASES = {
145 'default': {
146 # Use 'sqlite3', 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
147 'ENGINE': 'django.db.backends.mysql',
148 # 'ENGINE': 'django.db.backends.postgresql_psycopg2',
149 # DB name or path to database file if using sqlite3.
150 'NAME': 'mailman',
151 # The following settings are not used with sqlite3:
152 'USER': 'mailman',
153 'PASSWORD': 'pass',
154 # HOST: empty for localhost through domain sockets or '127.0.0.1' for
155 # localhost through TCP.
156 'HOST': 'dbhost',
157 # PORT: set to empty string for default.
158 'PORT': '',
159 }
160 # Example for PostgreSQL (recommanded for production):
161 #'default': {
162 # 'ENGINE': 'django.db.backends.postgresql_psycopg2',
163 # 'NAME': 'database_name',
164 # 'USER': 'database_user',
165 # 'PASSWORD': 'database_password',
166 # 'HOST': 'localhost',
167 #}
168}
169
170
171# If you're behind a proxy, use the X-Forwarded-Host header
172# See https://docs.djangoproject.com/en/1.8/ref/settings/#use-x-forwarded-host
173USE_X_FORWARDED_HOST = True
174
175# And if your proxy does your SSL encoding for you, set SECURE_PROXY_SSL_HEADER
176# https://docs.djangoproject.com/en/1.8/ref/settings/#secure-proxy-ssl-header
177# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
178# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_SCHEME', 'https')
179
180# Other security settings
181# SECURE_SSL_REDIRECT = True
182# If you set SECURE_SSL_REDIRECT to True, make sure the SECURE_REDIRECT_EXEMPT
183# contains at least this line:
184# SECURE_REDIRECT_EXEMPT = [
185# "archives/api/mailman/.*", # Request from Mailman.
186# ]
187# SESSION_COOKIE_SECURE = True
188# SECURE_CONTENT_TYPE_NOSNIFF = True
189# SECURE_BROWSER_XSS_FILTER = True
190# CSRF_COOKIE_SECURE = True
191# CSRF_COOKIE_HTTPONLY = True
192# X_FRAME_OPTIONS = 'DENY'
193
194
195# Password validation
196# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
197
198AUTH_PASSWORD_VALIDATORS = [
199 {
200 'NAME':
201'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
202 },
203 {
204 'NAME':
205'django.contrib.auth.password_validation.MinimumLengthValidator',
206 },
207 {
208 'NAME':
209'django.contrib.auth.password_validation.CommonPasswordValidator',
210 },
211 {
212 'NAME':
213'django.contrib.auth.password_validation.NumericPasswordValidator',
214 },
215]
216
217# Internationalization
218# https://docs.djangoproject.com/en/1.8/topics/i18n/
219
220LANGUAGE_CODE = 'en-us'
221
222TIME_ZONE = 'Europe/Berlin'
223
224USE_I18N = True
225
226USE_L10N = True
227
228USE_TZ = True
229
230
231# Static files (CSS, JavaScript, Images)
232# https://docs.djangoproject.com/en/1.8/howto/static-files/
233
234# Absolute path to the directory static files should be collected to.
235# Don't put anything in this directory yourself; store your static files
236# in apps' "static/" subdirectories and in STATICFILES_DIRS.
237# Example: "/var/www/example.com/static/"
238STATIC_ROOT = '/var/lib/mailman3/web/static'
239
240# URL prefix for static files.
241# Example: "http://example.com/static/", "http://static.example.com/"
242STATIC_URL = '/static/'
243
244# Additional locations of static files
245STATICFILES_DIRS = (
246 # Put strings here, like "/home/html/static" or "C:/www/django/static".
247 # Always use forward slashes, even on Windows.
248 # Don't forget to use absolute paths, not relative paths.
249 # BASE_DIR + '/static/',
250)
251
252# List of finder classes that know how to find static files in
253# various locations.
254STATICFILES_FINDERS = (
255 'django.contrib.staticfiles.finders.FileSystemFinder',
256 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
257 # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
258 'compressor.finders.CompressorFinder',
259)
260
261# Django 1.6+ defaults to a JSON serializer, but it won't work with
262# django-openid, see
263# https://bugs.launchpad.net/django-openid-auth/+bug/1252826
264SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
265
266
267LOGIN_URL = 'account_login'
268LOGIN_REDIRECT_URL = 'list_index'
269LOGOUT_URL = 'account_logout'
270
271
272# If you enable internal authentication, this is the address that the emails
273# will appear to be coming from. Make sure you set a valid domain name,
274# otherwise the emails may get rejected.
275# https://docs.djangoproject.com/en/1.8/ref/settings/#default-from-email
276# DEFAULT_FROM_EMAIL = "mailing-lists@you-domain.org"
277DEFAULT_FROM_EMAIL = 'admin@lists.ffnw.de'
278
279# If you enable email reporting for error messages, this is where those emails
280# will appear to be coming from. Make sure you set a valid domain name,
281# otherwise the emails may get rejected.
282# https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-SERVER_EMAIL
283# SERVER_EMAIL = 'root@your-domain.org'
284#SERVER_EMAIL = 'admin@lists.ffnw.de'
285
286# Change this when you have a real email backend
287#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
288
289# Compatibility with Bootstrap 3
290from django.contrib.messages import constants as messages # flake8: noqa
291MESSAGE_TAGS = {
292 messages.ERROR: 'danger'
293}
294
295
296#
297# Social auth
298#
299AUTHENTICATION_BACKENDS = (
300 'django.contrib.auth.backends.ModelBackend',
301 'allauth.account.auth_backends.AuthenticationBackend',
302)
303
304# Django Allauth
305ACCOUNT_AUTHENTICATION_METHOD = "username_email"
306ACCOUNT_EMAIL_REQUIRED = True
307ACCOUNT_EMAIL_VERIFICATION = "mandatory"
308# You probably want https in production, but this is a dev setup file
309ACCOUNT_DEFAULT_HTTP_PROTOCOL = "http"
310ACCOUNT_UNIQUE_EMAIL = True
311
312SOCIALACCOUNT_PROVIDERS = {
313 'openid': {
314 'SERVERS': [
315 dict(id='yahoo',
316 name='Yahoo',
317 openid_url='http://me.yahoo.com'),
318 ],
319 },
320 'google': {
321 'SCOPE': ['profile', 'email'],
322 'AUTH_PARAMS': {'access_type': 'online'},
323 },
324 'facebook': {
325 'METHOD': 'oauth2',
326 'SCOPE': ['email'],
327 'FIELDS': [
328 'email',
329 'name',
330 'first_name',
331 'last_name',
332 'locale',
333 'timezone',
334 ],
335 'VERSION': 'v2.4',
336 },
337}
338
339
340#
341# Gravatar
342# https://github.com/twaddington/django-gravatar
343#
344# gravatar base url.
345#GRAVATAR_URL = 'http://cdn.libravatar.org/'
346# Gravatar base secure https url.
347#GRAVATAR_SECURE_URL = 'https://seccdn.libravatar.org/'
348# Gravatar size in pixels.
349#GRAVATAR_DEFAULT_SIZE = '80'
350# An image url or one of the following: 'mm', 'identicon', 'monsterid',
351# 'wavatar', 'retro'.
352#GRAVATAR_DEFAULT_IMAGE = 'mm'
353# One of the following: 'g', 'pg', 'r', 'x'.
354#GRAVATAR_DEFAULT_RATING = 'g'
355# True to use https by default, False for plain http.
356#GRAVATAR_DEFAULT_SECURE = True
357
358#
359# django-compressor
360# https://pypi.python.org/pypi/django_compressor
361#
362COMPRESS_PRECOMPILERS = (
363 ('text/x-scss', 'sass -t compressed {infile} {outfile}'),
364 ('text/x-sass', 'sass -t compressed {infile} {outfile}'),
365)
366# On a production setup, setting COMPRESS_OFFLINE to True will bring a
367# significant performance improvement, as CSS files will not need to be
368# recompiled on each requests. It means running an additional "compress"
369# management command after each code upgrade.
370# http://django-compressor.readthedocs.io/en/latest/usage/#offline-compression
371COMPRESS_OFFLINE = False
372
373# Needed for debug mode
374# INTERNAL_IPS = ('127.0.0.1',)
375
376
377#
378# Full-text search engine
379#
380HAYSTACK_CONNECTIONS = {
381 'default': {
382 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
383 'PATH': '/var/lib/mailman3/web/fulltext_index',
384 # You can also use the Xapian engine, it's faster and more accurate,
385 # but requires another library.
386 # http://django-haystack.readthedocs.io/en/v2.4.1/installing_search_engines.html#xapian
387 # Example configuration for Xapian:
388 #'ENGINE': 'xapian_backend.XapianEngine'
389 },
390}
391
392
393#
394# Asynchronous tasks
395#
396Q_CLUSTER = {
397 'timeout': 300,
398 'save_limit': 100,
399 'orm': 'default',
400}
401
402
403# A sample logging configuration. The only tangible logging
404# performed by this configuration is to send an email to
405# the site admins on every HTTP 500 error when DEBUG=False.
406# See http://docs.djangoproject.com/en/dev/topics/logging for
407# more details on how to customize your logging configuration.
408
409
410# Using the cache infrastructure can significantly improve performance on a
411# production setup. This is an example with a local Memcached server.
412#CACHES = {
413# 'default': {
414# 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
415# 'LOCATION': '127.0.0.1:11211',
416# }
417#}
418
419
420# When DEBUG is True, don't actually send emails to the SMTP server, just store
421# them in a directory. This way you won't accidentally spam your mailing-lists
422# while you're fiddling with the code.
423if DEBUG == True:
424 EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
425 EMAIL_FILE_PATH = os.path.join(BASE_DIR, 'emails')
426
427
428#
429# HyperKitty-specific
430#
431
432# Only display mailing-lists from the same virtual host as the webserver
433FILTER_VHOST = False
434
435
436try:
437 from settings_local import *
438except ImportError:
439 pass