Merge branch 'explicit' into 'master'
[mailman-postorious.git] / example_project / settings.py
blob357aa0a6c321af31cf92abe762d589d27fb61e38
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 1998-2018 by the Free Software Foundation, Inc.
4 # This file is part of Postorius.
6 # Postorius is free software: you can redistribute it and/or modify it under
7 # 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.
11 # Postorius is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 # more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Postorius. If not, see <http://www.gnu.org/licenses/>.
19 """
20 Django settings for postorius project.
22 For more information on this file, see
23 https://docs.djangoproject.com/en/1.9/topics/settings/
25 For the full list of settings and their values, see
26 https://docs.djangoproject.com/en/1.9/ref/settings/
27 """
29 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
30 import os
32 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
35 # Quick-start development settings - unsuitable for production
36 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
38 # SECURITY WARNING: keep the secret key used in production secret!
39 SECRET_KEY = '$!-7^wl#wiifjbh)5@f7ji%x!vp7s1vzbvwt26hxv$idixq0u0'
41 # SECURITY WARNING: don't run with debug turned on in production!
42 DEBUG = True
44 ADMINS = (
45 #('Admin', 'webmaster@example.com'),
48 SITE_ID = 1
50 ALLOWED_HOSTS = []
52 # Mailman API credentials
53 MAILMAN_REST_API_URL = 'http://localhost:8001'
54 MAILMAN_REST_API_USER = 'restadmin'
55 MAILMAN_REST_API_PASS = 'restpass'
58 # Application definition
60 INSTALLED_APPS = (
61 'django.contrib.admin',
62 'django.contrib.auth',
63 'django.contrib.contenttypes',
64 'django.contrib.sessions',
65 'django.contrib.sites',
66 'django.contrib.messages',
67 'django.contrib.staticfiles',
68 'postorius',
69 'django_mailman3',
70 'django_gravatar',
71 'allauth',
72 'allauth.account',
73 'allauth.socialaccount',
74 'allauth.socialaccount.providers.openid',
75 'django_mailman3.lib.auth.fedora',
76 'allauth.socialaccount.providers.github',
77 'allauth.socialaccount.providers.gitlab',
78 'allauth.socialaccount.providers.google',
79 # 'allauth.socialaccount.providers.facebook',
80 'allauth.socialaccount.providers.twitter',
81 'allauth.socialaccount.providers.stackexchange',
85 MIDDLEWARE = (
86 'django.contrib.sessions.middleware.SessionMiddleware',
87 'django.middleware.common.CommonMiddleware',
88 'django.middleware.csrf.CsrfViewMiddleware',
89 'django.middleware.locale.LocaleMiddleware',
90 'django.contrib.auth.middleware.AuthenticationMiddleware',
91 'django.contrib.messages.middleware.MessageMiddleware',
92 'django.middleware.clickjacking.XFrameOptionsMiddleware',
93 'django.middleware.security.SecurityMiddleware',
94 'postorius.middleware.PostoriusMiddleware',
97 # Set `postorius.urls` as main url config if Postorius
98 # is the only app you want to serve.
99 ROOT_URLCONF = 'urls'
102 TEMPLATES = [
104 'BACKEND': 'django.template.backends.django.DjangoTemplates',
105 'DIRS': [],
106 'APP_DIRS': True,
107 'OPTIONS': {
108 'context_processors': [
109 'django.template.context_processors.debug',
110 'django.template.context_processors.i18n',
111 'django.template.context_processors.media',
112 'django.template.context_processors.static',
113 'django.template.context_processors.tz',
114 'django.template.context_processors.csrf',
115 'django.template.context_processors.request',
116 'django.contrib.auth.context_processors.auth',
117 'django.contrib.messages.context_processors.messages',
118 'django_mailman3.context_processors.common',
119 'postorius.context_processors.postorius',
125 WSGI_APPLICATION = 'wsgi.application'
128 # Database
129 # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
131 DATABASES = {
132 'default': {
133 'ENGINE': 'django.db.backends.sqlite3',
134 'NAME': os.path.join(BASE_DIR, 'postorius.db'),
138 # Password validation
139 # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
141 AUTH_PASSWORD_VALIDATORS = [
143 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
146 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
149 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
152 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
156 # Internationalization
157 # https://docs.djangoproject.com/en/1.9/topics/i18n/
159 LANGUAGE_CODE = 'en-us'
161 TIME_ZONE = 'UTC'
163 USE_I18N = True
165 USE_L10N = True
167 USE_TZ = True
170 # Static files (CSS, JavaScript, Images)
171 # https://docs.djangoproject.com/en/1.9/howto/static-files/
174 # Absolute path to the directory static files should be collected to.
175 # Don't put anything in this directory yourself; store your static files
176 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
177 # Example: "/var/www/example.com/static/"
178 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
180 # URL prefix for static files.
181 # Example: "http://example.com/static/", "http://static.example.com/"
182 STATIC_URL = '/static/'
184 LOGIN_URL = 'account_login'
185 LOGIN_REDIRECT_URL = 'list_index'
186 LOGOUT_URL = 'account_logout'
190 # From Address for emails sent to users
191 DEFAULT_FROM_EMAIL = 'postorius@localhost.local'
192 # From Address for emails sent to admins
193 SERVER_EMAIL = 'root@localhost.local'
194 # Compatibility with Bootstrap 3
195 from django.contrib.messages import constants as messages
196 MESSAGE_TAGS = {
197 messages.ERROR: 'danger'
201 AUTHENTICATION_BACKENDS = (
202 'django.contrib.auth.backends.ModelBackend',
203 'allauth.account.auth_backends.AuthenticationBackend',
206 # Django Allauth
207 ACCOUNT_AUTHENTICATION_METHOD = "username_email"
208 ACCOUNT_EMAIL_REQUIRED = True
209 ACCOUNT_EMAIL_VERIFICATION = "mandatory"
210 ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
211 ACCOUNT_UNIQUE_EMAIL = True
213 SOCIALACCOUNT_PROVIDERS = {
214 'openid': {
215 'SERVERS': [
216 dict(id='yahoo',
217 name='Yahoo',
218 openid_url='http://me.yahoo.com'),
221 'google': {
222 'SCOPE': ['profile', 'email'],
223 'AUTH_PARAMS': {'access_type': 'online'},
225 'facebook': {
226 'METHOD': 'oauth2',
227 'SCOPE': ['email'],
228 'FIELDS': [
229 'email',
230 'name',
231 'first_name',
232 'last_name',
233 'locale',
234 'timezone',
236 'VERSION': 'v2.4',
242 # These can be set to override the defaults but are not mandatory:
243 # EMAIL_CONFIRMATION_TEMPLATE = 'postorius/address_confirmation_message.txt'
244 # EMAIL_CONFIRMATION_SUBJECT = 'Confirmation needed'
247 LOGGING = {
248 'version': 1,
249 'disable_existing_loggers': False,
250 'handlers': {
251 'console': {
252 'class': 'logging.StreamHandler',
253 'formatter': 'simple',
255 'file':{
256 'level': 'INFO',
257 #'class': 'logging.handlers.RotatingFileHandler',
258 'class': 'logging.handlers.WatchedFileHandler',
259 'filename': os.path.join(BASE_DIR, 'logs', 'postorius.log'),
260 'formatter': 'verbose',
263 'loggers': {
264 'django': {
265 'handlers': ['console', 'file'],
266 'level': 'INFO',
268 'django.request': {
269 'handlers': ['console', 'file'],
270 'level': 'ERROR',
272 'postorius': {
273 'handlers': ['console', 'file'],
274 'level': 'INFO',
277 'formatters': {
278 'simple': {
279 'format': '%(levelname)s: %(message)s'
281 'verbose': {
282 'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s'
288 try:
289 from settings_local import *
290 except ImportError:
291 pass