diff --git a/roles/mailman/templates/settings.py.j2 b/roles/mailman/templates/settings.py.j2 index e5e84b1882..12140e669a 100644 --- a/roles/mailman/templates/settings.py.j2 +++ b/roles/mailman/templates/settings.py.j2 @@ -12,14 +12,12 @@ SECRET_KEY = '{{ mailman_hyperkitty_cookie_key }}' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False -TEMPLATE_DEBUG = DEBUG - ADMINS = ( ('HyperKitty Admin', 'abompard@fedoraproject.org'), ) # Hosts/domain names that are valid for this site; required if DEBUG is False -# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts +# See https://docs.djangoproject.com/en/1.8/ref/settings/#allowed-hosts ALLOWED_HOSTS = [ {% for host in mailman_domains %} "{{ host }}", @@ -47,16 +45,16 @@ MAILMAN_ARCHIVER_FROM = ('127.0.0.1', '::1') # Application definition INSTALLED_APPS = ( + # Uncomment the next line to enable the admin: + 'django.contrib.admin', + # Uncomment the next line to enable admin documentation: + # 'django.contrib.admindocs', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', #'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', - # Uncomment the next line to enable the admin: - 'django.contrib.admin', - # Uncomment the next line to enable admin documentation: - # 'django.contrib.admindocs', 'hyperkitty', 'social.apps.django_app.default', 'rest_framework', @@ -69,31 +67,59 @@ INSTALLED_APPS = ( 'django_extensions', 'postorius', ) -import django -if django.VERSION[:2] < (1, 7): - INSTALLED_APPS = INSTALLED_APPS + ("south",) MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', + 'django.middleware.locale.LocaleMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', - # Uncomment the next line for simple clickjacking protection: - # 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.security.SecurityMiddleware', #'hyperkitty.middleware.SSLRedirect', 'hyperkitty.middleware.TimezoneMiddleware', + 'postorius.middleware.PostoriusMiddleware', ) ROOT_URLCONF = 'urls' -# CSS theme for postorius -MAILMAN_THEME = "default" + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + '{{ mailman_webui_basedir }}/templates', + ], + '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', + 'social.apps.django_app.context_processors.backends', + 'social.apps.django_app.context_processors.login_redirect', + 'hyperkitty.context_processors.export_settings', + 'hyperkitty.context_processors.postorius_info', + 'postorius.context_processors.postorius', + ], + }, + }, +] + +WSGI_APPLICATION = 'wsgi.application' # Database -# https://docs.djangoproject.com/en/1.6/ref/settings/#databases +# https://docs.djangoproject.com/en/1.8/ref/settings/#databases DATABASES = { 'default': { @@ -108,14 +134,14 @@ DATABASES = { # We're behind a proxy, use the X-Forwarded-Host header -# See https://docs.djangoproject.com/en/1.5/ref/settings/#use-x-forwarded-host +# See https://docs.djangoproject.com/en/1.8/ref/settings/#use-x-forwarded-host USE_X_FORWARDED_HOST = True # In the Fedora infra, requests are systematically redirected to HTTPS, so put # something always true here: SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_SCHEME', 'https') # Internationalization -# https://docs.djangoproject.com/en/1.6/topics/i18n/ +# https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -129,16 +155,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.6/howto/static-files/ - -# Absolute filesystem path to the directory that will hold user-uploaded files. -# Example: "/var/www/example.com/media/" -MEDIA_ROOT = '' - -# URL that handles the media served from MEDIA_ROOT. Make sure to use a -# trailing slash. -# Examples: "http://example.com/media/", "http://media.example.com/" -MEDIA_URL = '' +# https://docs.djangoproject.com/en/1.8/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 @@ -167,54 +184,40 @@ STATICFILES_FINDERS = ( 'compressor.finders.CompressorFinder', ) - -TEMPLATE_CONTEXT_PROCESSORS = ( - "django.contrib.auth.context_processors.auth", - "django.contrib.messages.context_processors.messages", - "django.core.context_processors.debug", - "django.core.context_processors.i18n", - "django.core.context_processors.media", - "django.core.context_processors.static", - "django.core.context_processors.csrf", - "django.core.context_processors.request", - "django.core.context_processors.tz", - "django.contrib.messages.context_processors.messages", - "social.apps.django_app.context_processors.backends", - "social.apps.django_app.context_processors.login_redirect", - "hyperkitty.context_processors.export_settings", - "hyperkitty.context_processors.postorius_info", - "postorius.context_processors.postorius", -) - -TEMPLATE_DIRS = ( - # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". - # Always use forward slashes, even on Windows. - # Don't forget to use absolute paths, not relative paths. - '{{ mailman_webui_basedir }}/templates', -) - # Django 1.6+ defaults to a JSON serializer, but it won't work with django-openid, see # https://bugs.launchpad.net/django-openid-auth/+bug/1252826 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' LOGIN_URL = 'hk_user_login' -LOGOUT_URL = 'hk_user_logout' LOGIN_REDIRECT_URL = 'hk_root' +LOGOUT_URL = 'hk_user_logout' -# Use the email as identifier, but truncate it because the User.username field -# is only 30 chars long. -BROWSERID_USERNAME_ALGO = lambda email: email[:30] +# Use the email username as identifier, but truncate it because +# the User.username field is only 30 chars long. +def username(email): + return email.rsplit('@', 1)[0][:30] +BROWSERID_USERNAME_ALGO = username BROWSERID_VERIFY_CLASS = "django_browserid.views.Verify" DEFAULT_FROM_EMAIL = "admin@fedoraproject.org" +# Compatibility with Bootstrap 3 +from django.contrib.messages import constants as messages +MESSAGE_TAGS = { + messages.ERROR: 'danger' + } + +# Django Crispy Forms +CRISPY_TEMPLATE_PACK = 'bootstrap3' +CRISPY_FAIL_SILENTLY = not DEBUG + + # # Social auth # - AUTHENTICATION_BACKENDS = ( #'social.backends.open_id.OpenIdAuth', # http://python-social-auth.readthedocs.org/en/latest/backends/google.html @@ -227,12 +230,6 @@ AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', ) -# http://python-social-auth.readthedocs.org/en/latest/configuration/django.html#database -if django.VERSION[:2] < (1, 7): - SOUTH_MIGRATION_MODULES = { - 'default': 'social.apps.django_app.default.south_migrations' - } - # http://python-social-auth.readthedocs.org/en/latest/pipeline.html#authentication-pipeline SOCIAL_AUTH_PIPELINE = ( 'social.pipeline.social_auth.social_details', @@ -248,6 +245,7 @@ SOCIAL_AUTH_PIPELINE = ( 'social.pipeline.social_auth.associate_user', 'social.pipeline.social_auth.load_extra_data', 'social.pipeline.user.user_details', + 'hyperkitty.lib.mailman.add_user_to_mailman', ) @@ -282,16 +280,6 @@ COMPRESS_OFFLINE = True # needed for debug mode #INTERNAL_IPS = ('127.0.0.1',) -# Django Crispy Forms -CRISPY_TEMPLATE_PACK = 'bootstrap3' -CRISPY_FAIL_SILENTLY = not DEBUG - -# Compatibility with Bootstrap 3 -from django.contrib.messages import constants as messages -MESSAGE_TAGS = { - messages.ERROR: 'danger' - } - # # Full-text search engine @@ -324,7 +312,7 @@ LOGGING = { 'class': 'django.utils.log.AdminEmailHandler' }, 'file':{ - 'level': 'INFO', + 'level': 'DEBUG', #'class': 'logging.handlers.RotatingFileHandler', 'class': 'logging.handlers.WatchedFileHandler', 'filename': '/var/log/hyperkitty/hyperkitty.log', @@ -333,29 +321,14 @@ LOGGING = { }, 'loggers': { 'django.request': { - 'handlers': ['mail_admins'], - 'level': 'ERROR', - 'propagate': True, - }, - 'django.request': { - 'handlers': ['file'], - 'level': 'ERROR', - 'propagate': True, - }, - 'django': { - 'handlers': ['file'], - 'level': 'ERROR', - 'propagate': True, - }, - 'hyperkitty': { - 'handlers': ['file'], + 'handlers': ['mail_admins', 'file'], 'level': 'DEBUG', 'propagate': True, }, }, 'formatters': { 'verbose': { - 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' + 'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s' }, 'simple': { 'format': '%(levelname)s %(message)s'