chore: Bump copyright year
[mailman-postorious.git] / example_project / settings.py
blob7beb67989cafb2300253c860429e48ddc38961e6
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 1998-2023 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 # Compatibility with Bootstrap 3
33 from django.contrib.messages import constants as messages
36 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
39 # Quick-start development settings - unsuitable for production
40 # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
42 # SECURITY WARNING: keep the secret key used in production secret!
43 SECRET_KEY = '$!-7^wl#wiifjbh)5@f7ji%x!vp7s1vzbvwt26hxv$idixq0u0'
45 # SECURITY WARNING: don't run with debug turned on in production!
46 DEBUG = True
48 ADMINS = (
49 # ('Admin', 'webmaster@example.com'),
52 SITE_ID = 1
54 ALLOWED_HOSTS = []
56 # Mailman API credentials
57 MAILMAN_REST_API_URL = 'http://localhost:8001'
58 MAILMAN_REST_API_USER = 'restadmin'
59 MAILMAN_REST_API_PASS = 'restpass'
62 # Application definition
64 INSTALLED_APPS = (
65 'django.contrib.admin',
66 'django.contrib.auth',
67 'django.contrib.contenttypes',
68 'django.contrib.sessions',
69 'django.contrib.sites',
70 'django.contrib.messages',
71 'django.contrib.staticfiles',
72 'postorius',
73 'django_mailman3',
74 'django_gravatar',
75 'allauth',
76 'allauth.account',
77 'allauth.socialaccount',
78 'allauth.socialaccount.providers.openid',
79 'django_mailman3.lib.auth.fedora',
80 'allauth.socialaccount.providers.github',
81 'allauth.socialaccount.providers.gitlab',
82 'allauth.socialaccount.providers.google',
83 # 'allauth.socialaccount.providers.facebook',
84 'allauth.socialaccount.providers.twitter',
85 'allauth.socialaccount.providers.stackexchange',
86 # Dev only dependencies. Do not include in any production site.
87 'debug_toolbar',
88 'requests_panel',
92 MIDDLEWARE = [
93 'django.contrib.sessions.middleware.SessionMiddleware',
94 # NOTE: Do not include DebugToolbarMiddleware in any production site.
95 'debug_toolbar.middleware.DebugToolbarMiddleware',
96 'django.middleware.common.CommonMiddleware',
97 'django.middleware.csrf.CsrfViewMiddleware',
98 'django.middleware.locale.LocaleMiddleware',
99 'django.contrib.auth.middleware.AuthenticationMiddleware',
100 'django.contrib.messages.middleware.MessageMiddleware',
101 'django.middleware.clickjacking.XFrameOptionsMiddleware',
102 'django.middleware.security.SecurityMiddleware',
103 'django_mailman3.middleware.TimezoneMiddleware',
104 'postorius.middleware.PostoriusMiddleware',
107 # Set `postorius.urls` as main url config if Postorius
108 # is the only app you want to serve.
109 ROOT_URLCONF = 'urls'
112 TEMPLATES = [
114 'BACKEND': 'django.template.backends.django.DjangoTemplates',
115 'DIRS': [],
116 'APP_DIRS': True,
117 'OPTIONS': {
118 'context_processors': [
119 'django.template.context_processors.debug',
120 'django.template.context_processors.i18n',
121 'django.template.context_processors.media',
122 'django.template.context_processors.static',
123 'django.template.context_processors.tz',
124 'django.template.context_processors.csrf',
125 'django.template.context_processors.request',
126 'django.contrib.auth.context_processors.auth',
127 'django.contrib.messages.context_processors.messages',
128 'django_mailman3.context_processors.common',
129 'postorius.context_processors.postorius',
135 WSGI_APPLICATION = 'wsgi.application'
138 # Database
139 # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
141 DATABASES = {
142 'default': {
143 'ENGINE': 'django.db.backends.sqlite3',
144 'NAME': os.path.join(BASE_DIR, 'postorius.db'),
148 # Maintain type of autogenerated keys going forward
149 # https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-auto-created-primary-keys
150 DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
152 # Password validation
153 # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
155 AUTH_PASSWORD_VALIDATORS = [
157 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
160 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
163 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
166 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
170 # Internationalization
171 # https://docs.djangoproject.com/en/1.9/topics/i18n/
173 LANGUAGE_CODE = 'en-us'
175 TIME_ZONE = 'UTC'
177 USE_I18N = True
179 USE_L10N = True
181 USE_TZ = True
184 # Static files (CSS, JavaScript, Images)
185 # https://docs.djangoproject.com/en/1.9/howto/static-files/
188 # Absolute path to the directory static files should be collected to.
189 # Don't put anything in this directory yourself; store your static files
190 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
191 # Example: "/var/www/example.com/static/"
192 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
194 # URL prefix for static files.
195 # Example: "http://example.com/static/", "http://static.example.com/"
196 STATIC_URL = '/static/'
198 LOGIN_URL = 'account_login'
199 LOGIN_REDIRECT_URL = 'list_index'
200 LOGOUT_URL = 'account_logout'
203 # From Address for emails sent to users
204 DEFAULT_FROM_EMAIL = 'postorius@localhost.local'
205 # From Address for emails sent to admins
206 SERVER_EMAIL = 'root@localhost.local'
207 MESSAGE_TAGS = {messages.ERROR: 'danger'}
210 AUTHENTICATION_BACKENDS = (
211 'django.contrib.auth.backends.ModelBackend',
212 'allauth.account.auth_backends.AuthenticationBackend',
215 # Django Allauth
216 ACCOUNT_AUTHENTICATION_METHOD = 'username_email'
217 ACCOUNT_EMAIL_REQUIRED = True
218 ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
219 ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
220 ACCOUNT_UNIQUE_EMAIL = True
222 SOCIALACCOUNT_PROVIDERS = {
223 'openid': {
224 'SERVERS': [
225 dict(id='yahoo', name='Yahoo', openid_url='http://me.yahoo.com'),
228 'google': {
229 'SCOPE': ['profile', 'email'],
230 'AUTH_PARAMS': {'access_type': 'online'},
232 'facebook': {
233 'METHOD': 'oauth2',
234 'SCOPE': ['email'],
235 'FIELDS': [
236 'email',
237 'name',
238 'first_name',
239 'last_name',
240 'locale',
241 'timezone',
243 'VERSION': 'v2.4',
248 # These can be set to override the defaults but are not mandatory:
249 # EMAIL_CONFIRMATION_TEMPLATE = 'postorius/address_confirmation_message.txt'
250 # EMAIL_CONFIRMATION_SUBJECT = 'Confirmation needed'
253 LOGGING = {
254 'version': 1,
255 'disable_existing_loggers': False,
256 'handlers': {
257 'console': {
258 'class': 'logging.StreamHandler',
259 'formatter': 'simple',
261 'file': {
262 'level': 'INFO',
263 #'class': 'logging.handlers.RotatingFileHandler',
264 'class': 'logging.handlers.WatchedFileHandler',
265 'filename': os.path.join(BASE_DIR, 'logs', 'postorius.log'),
266 'formatter': 'verbose',
269 'loggers': {
270 'django': {
271 'handlers': ['console', 'file'],
272 'level': 'INFO',
274 'django.request': {
275 'handlers': ['console', 'file'],
276 'level': 'ERROR',
278 'postorius': {
279 'handlers': ['console', 'file'],
280 'level': 'DEBUG',
283 'formatters': {
284 'simple': {'format': '%(levelname)s: %(message)s'},
285 'verbose': {
286 'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s'
292 POSTORIUS_TEMPLATE_BASE_URL = 'http://localhost:8000'
294 #: Debug the API calls made by Postorius.
295 POSTORIUS_API_DEBUG = False
297 if DEBUG and POSTORIUS_API_DEBUG:
298 MIDDLEWARE.append('postorius.middleware.APICountingMiddleware')
301 # Needed for django debug toolbar to show up.
302 INTERNAL_IPS = ('127.0.0.1',)
304 # List of panels that show up for django-debug-toolbar. They are
305 # very useful for debugging and are ONLY REQUIRED FOR TESTING.
306 DEBUG_TOOLBAR_PANELS = [
307 'requests_panel.panel.RequestsDebugPanel',
308 'debug_toolbar.panels.sql.SQLPanel',
309 'debug_toolbar.panels.templates.TemplatesPanel',
310 'debug_toolbar.panels.history.HistoryPanel',
311 'debug_toolbar.panels.versions.VersionsPanel',
312 'debug_toolbar.panels.timer.TimerPanel',
313 'debug_toolbar.panels.settings.SettingsPanel',
314 'debug_toolbar.panels.headers.HeadersPanel',
315 'debug_toolbar.panels.request.RequestPanel',
316 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
317 'debug_toolbar.panels.cache.CachePanel',
318 'debug_toolbar.panels.signals.SignalsPanel',
319 'debug_toolbar.panels.logging.LoggingPanel',
320 'debug_toolbar.panels.redirects.RedirectsPanel',
321 'debug_toolbar.panels.profiling.ProfilingPanel',
324 try:
325 from settings_local import *
326 except ImportError:
327 pass