dev: Commit some visual studio code configuration.
[mailman-postorious.git] / example_project / settings.py
blob1fae6beed3bcf720e331340877199640ac2302b1
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 1998-2022 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',
87 # Dev only dependencies. Do not include in any production site.
88 'debug_toolbar',
89 'requests_panel',
93 MIDDLEWARE = [
94 'django.contrib.sessions.middleware.SessionMiddleware',
95 # NOTE: Do not include DebugToolbarMiddleware in any production site.
96 'debug_toolbar.middleware.DebugToolbarMiddleware',
97 'django.middleware.common.CommonMiddleware',
98 'django.middleware.csrf.CsrfViewMiddleware',
99 'django.middleware.locale.LocaleMiddleware',
100 'django.contrib.auth.middleware.AuthenticationMiddleware',
101 'django.contrib.messages.middleware.MessageMiddleware',
102 'django.middleware.clickjacking.XFrameOptionsMiddleware',
103 'django.middleware.security.SecurityMiddleware',
104 'django_mailman3.middleware.TimezoneMiddleware',
105 'postorius.middleware.PostoriusMiddleware',
108 # Set `postorius.urls` as main url config if Postorius
109 # is the only app you want to serve.
110 ROOT_URLCONF = 'urls'
113 TEMPLATES = [
115 'BACKEND': 'django.template.backends.django.DjangoTemplates',
116 'DIRS': [],
117 'APP_DIRS': True,
118 'OPTIONS': {
119 'context_processors': [
120 'django.template.context_processors.debug',
121 'django.template.context_processors.i18n',
122 'django.template.context_processors.media',
123 'django.template.context_processors.static',
124 'django.template.context_processors.tz',
125 'django.template.context_processors.csrf',
126 'django.template.context_processors.request',
127 'django.contrib.auth.context_processors.auth',
128 'django.contrib.messages.context_processors.messages',
129 'django_mailman3.context_processors.common',
130 'postorius.context_processors.postorius',
136 WSGI_APPLICATION = 'wsgi.application'
139 # Database
140 # https://docs.djangoproject.com/en/1.9/ref/settings/#databases
142 DATABASES = {
143 'default': {
144 'ENGINE': 'django.db.backends.sqlite3',
145 'NAME': os.path.join(BASE_DIR, 'postorius.db'),
149 # Maintain type of autogenerated keys going forward
150 # https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-auto-created-primary-keys
151 DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
153 # Password validation
154 # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
156 AUTH_PASSWORD_VALIDATORS = [
158 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
161 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
164 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
167 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
171 # Internationalization
172 # https://docs.djangoproject.com/en/1.9/topics/i18n/
174 LANGUAGE_CODE = 'en-us'
176 TIME_ZONE = 'UTC'
178 USE_I18N = True
180 USE_L10N = True
182 USE_TZ = True
185 # Static files (CSS, JavaScript, Images)
186 # https://docs.djangoproject.com/en/1.9/howto/static-files/
189 # Absolute path to the directory static files should be collected to.
190 # Don't put anything in this directory yourself; store your static files
191 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
192 # Example: "/var/www/example.com/static/"
193 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
195 # URL prefix for static files.
196 # Example: "http://example.com/static/", "http://static.example.com/"
197 STATIC_URL = '/static/'
199 LOGIN_URL = 'account_login'
200 LOGIN_REDIRECT_URL = 'list_index'
201 LOGOUT_URL = 'account_logout'
205 # From Address for emails sent to users
206 DEFAULT_FROM_EMAIL = 'postorius@localhost.local'
207 # From Address for emails sent to admins
208 SERVER_EMAIL = 'root@localhost.local'
209 MESSAGE_TAGS = {
210 messages.ERROR: 'danger'
214 AUTHENTICATION_BACKENDS = (
215 'django.contrib.auth.backends.ModelBackend',
216 'allauth.account.auth_backends.AuthenticationBackend',
219 # Django Allauth
220 ACCOUNT_AUTHENTICATION_METHOD = "username_email"
221 ACCOUNT_EMAIL_REQUIRED = True
222 ACCOUNT_EMAIL_VERIFICATION = "mandatory"
223 ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
224 ACCOUNT_UNIQUE_EMAIL = True
226 SOCIALACCOUNT_PROVIDERS = {
227 'openid': {
228 'SERVERS': [
229 dict(id='yahoo',
230 name='Yahoo',
231 openid_url='http://me.yahoo.com'),
234 'google': {
235 'SCOPE': ['profile', 'email'],
236 'AUTH_PARAMS': {'access_type': 'online'},
238 'facebook': {
239 'METHOD': 'oauth2',
240 'SCOPE': ['email'],
241 'FIELDS': [
242 'email',
243 'name',
244 'first_name',
245 'last_name',
246 'locale',
247 'timezone',
249 'VERSION': 'v2.4',
255 # These can be set to override the defaults but are not mandatory:
256 # EMAIL_CONFIRMATION_TEMPLATE = 'postorius/address_confirmation_message.txt'
257 # EMAIL_CONFIRMATION_SUBJECT = 'Confirmation needed'
260 LOGGING = {
261 'version': 1,
262 'disable_existing_loggers': False,
263 'handlers': {
264 'console': {
265 'class': 'logging.StreamHandler',
266 'formatter': 'simple',
268 'file':{
269 'level': 'INFO',
270 #'class': 'logging.handlers.RotatingFileHandler',
271 'class': 'logging.handlers.WatchedFileHandler',
272 'filename': os.path.join(BASE_DIR, 'logs', 'postorius.log'),
273 'formatter': 'verbose',
276 'loggers': {
277 'django': {
278 'handlers': ['console', 'file'],
279 'level': 'INFO',
281 'django.request': {
282 'handlers': ['console', 'file'],
283 'level': 'ERROR',
285 'postorius': {
286 'handlers': ['console', 'file'],
287 'level': 'DEBUG',
290 'formatters': {
291 'simple': {
292 'format': '%(levelname)s: %(message)s'
294 'verbose': {
295 'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s'
301 POSTORIUS_TEMPLATE_BASE_URL = "http://localhost:8000"
303 #: Debug the API calls made by Postorius.
304 POSTORIUS_API_DEBUG = False
306 if DEBUG and POSTORIUS_API_DEBUG:
307 MIDDLEWARE.append('postorius.middleware.APICountingMiddleware')
310 # Needed for django debug toolbar to show up.
311 INTERNAL_IPS = ('127.0.0.1',)
313 # List of panels that show up for django-debug-toolbar. They are
314 # very useful for debugging and are ONLY REQUIRED FOR TESTING.
315 DEBUG_TOOLBAR_PANELS = [
316 'requests_panel.panel.RequestsDebugPanel',
317 'debug_toolbar.panels.sql.SQLPanel',
318 'debug_toolbar.panels.templates.TemplatesPanel',
320 'debug_toolbar.panels.history.HistoryPanel',
321 'debug_toolbar.panels.versions.VersionsPanel',
322 'debug_toolbar.panels.timer.TimerPanel',
323 'debug_toolbar.panels.settings.SettingsPanel',
324 'debug_toolbar.panels.headers.HeadersPanel',
325 'debug_toolbar.panels.request.RequestPanel',
326 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
327 'debug_toolbar.panels.cache.CachePanel',
328 'debug_toolbar.panels.signals.SignalsPanel',
329 'debug_toolbar.panels.logging.LoggingPanel',
330 'debug_toolbar.panels.redirects.RedirectsPanel',
331 'debug_toolbar.panels.profiling.ProfilingPanel',
335 try:
336 from settings_local import *
337 except ImportError:
338 pass