# -*- coding: utf-8 -*- """ Django settings for HyperKitty + Postorius """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os # Compatibility with Bootstrap 3 from django.contrib.messages import constants as messages BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '$!-7^wl#wiifjbh)5@f7ji%x!vp7s1vzbvwt26hxv$idixq0u0' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False ADMINS = ( ('Admin', 'postmaster@restart.be'), ) SITE_ID = 1 ALLOWED_HOSTS = ['server fqdn', 'lists', 'ip.ad.dr.ess'] # Mailman API credentials MAILMAN_REST_API_URL = 'http://127.0.0.1:8001' MAILMAN_REST_API_USER = 'restadmin' MAILMAN_REST_API_PASS = 'restpass' MAILMAN_ARCHIVER_KEY = 'SecretArchiverAPIKey' MAILMAN_ARCHIVER_FROM = ('ip.ad.dr.ess') # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'hyperkitty', 'rest_framework', 'compressor', 'haystack', 'django_extensions', 'django_q', 'postorius', 'django_mailman3', 'django_gravatar', 'allauth', 'allauth.account', 'allauth.socialaccount', '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', ) # Set `postorius.urls` as main url config if Postorius # is the only app you want to serve. 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', 'postorius.context_processors.postorius', ], }, }, ] WSGI_APPLICATION = 'wsgi.application' # Database # https://docs.djangoproject.com/en/1.9/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'postorius.db'), } } # 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.9/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Europe/Brussels' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.9/howto/static-files/ # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/var/www/example.com/static/" STATIC_ROOT = os.path.join(BASE_DIR, 'static') # URL prefix for static files. # Example: "http://example.com/static/", "http://static.example.com/" STATIC_URL = '/static/' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', 'compressor.finders.CompressorFinder', ) LOGIN_URL = 'account_login' LOGIN_REDIRECT_URL = 'list_index' LOGOUT_URL = 'account_logout' # LOGIN_URL = 'hk_user_login' # LOGOUT_URL = 'hk_user_logout' # LOGIN_REDIRECT_URL = 'hk_root' # From Address for emails sent to users DEFAULT_FROM_EMAIL = 'mailman3@fqdn' # From Address for emails sent to admins SERVER_EMAIL = 'mailman3@fqdn' MESSAGE_TAGS = { messages.ERROR: 'danger' } AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend', ) # Django Allauth ACCOUNT_AUTHENTICATION_METHOD = "username_email" ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = "mandatory" 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', }, } # # django-compressor # https://pypi.python.org/pypi/django_compressor # COMPRESS_PRECOMPILERS = ( ('text/x-scss', 'sass {infile} {outfile}'), ('text/x-sass', 'sass {infile} {outfile}'), ) COMPRESS_OFFLINE = True # These can be set to override the defaults but are not mandatory: # EMAIL_CONFIRMATION_TEMPLATE = 'postorius/address_confirmation_message.txt' # EMAIL_CONFIRMATION_SUBJECT = 'Confirmation needed' LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'formatter': 'simple', }, 'file':{ 'level': 'INFO', #'class': 'logging.handlers.RotatingFileHandler', 'class': 'logging.handlers.WatchedFileHandler', 'filename': os.path.join(BASE_DIR, 'logs', 'postorius.log'), 'formatter': 'verbose', }, }, 'loggers': { 'django': { 'handlers': ['console', 'file'], 'level': 'ERROR', }, 'django.request': { 'handlers': ['console', 'file'], 'level': 'ERROR', }, 'postorius': { 'handlers': ['console', 'file'], 'level': 'ERROR', }, 'hyperkitty': { 'handlers': ['file'], 'level': 'INFO', 'propagate': True, }, }, 'formatters': { 'simple': { 'format': '%(levelname)s: %(message)s' }, 'verbose': { 'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s' }, }, } HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', 'PATH': os.path.join(BASE_DIR, "fulltext_index"), }, } Q_CLUSTER = { 'name': 'mailman3', 'workers': 2, 'recycle': 500, 'timeout': 60, 'compress': True, 'save_limit': 250, 'queue_limit': 500, 'cpu_affinity': 1, 'bulk': 10, 'orm': 'default', } POSTORIUS_TEMPLATE_BASE_URL = "http://127.0.0.1:8000" try: from settings_local import * except ImportError: pass