X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/ae60b2a3949e96357477cc04f90fd0873cee8a92..031b8be3bf03baa724dd7e225b0555726d089341:/src/wolnelektury/settings/__init__.py?ds=sidebyside diff --git a/src/wolnelektury/settings/__init__.py b/src/wolnelektury/settings/__init__.py index 5d19d2651..113c1e731 100644 --- a/src/wolnelektury/settings/__init__.py +++ b/src/wolnelektury/settings/__init__.py @@ -1,8 +1,13 @@ -# -*- coding: utf-8 -*- +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# # Django settings for wolnelektury project. +import sentry_sdk +from sentry_sdk.integrations.django import DjangoIntegration + +from .apps import * from .basic import * from .auth import * -from .cache import * from .celery import * from .contrib import * from .custom import * @@ -10,108 +15,43 @@ from .locale import * from .static import * from .paths import * +# Load localsettings, if they exist +try: + from wolnelektury.localsettings import * +except ImportError: + pass -TEMPLATE_CONTEXT_PROCESSORS = ( - 'django.contrib.auth.context_processors.auth', - 'django.core.context_processors.debug', - 'django.core.context_processors.i18n', - 'django.core.context_processors.media', - 'django.core.context_processors.request', - 'wolnelektury.context_processors.extra_settings', - 'search.context_processors.search_form', -) - -MIDDLEWARE_CLASSES = [ - 'django.middleware.csrf.CsrfViewMiddleware', - 'ssify.middleware.SsiMiddleware', - 'django.middleware.cache.UpdateCacheMiddleware', - 'ssify.middleware.PrepareForCacheMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.admindocs.middleware.XViewMiddleware', - 'pagination.middleware.PaginationMiddleware', - 'ssify.middleware.LocaleMiddleware', - 'maintenancemode.middleware.MaintenanceModeMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'fnpdjango.middleware.SetRemoteAddrFromXRealIP', - 'django.middleware.cache.FetchFromCacheMiddleware', -] - -ROOT_URLCONF = 'wolnelektury.urls' -# These are the ones we should test. -INSTALLED_APPS_OUR = [ - 'wolnelektury', - # our - 'ajaxable', - 'api', - 'catalogue', - 'chunks', - 'dictionary', - 'infopages', - 'lesmianator', - 'newtagging', - 'opds', - 'pdcounter', - 'reporting', - 'sponsors', - 'stats', - 'suggest', - 'picture', - 'social', - 'waiter', - 'search', - 'oai', - 'funding', - 'polls', - 'libraries', - ] +# If Celery broker not configured, enable always-eager mode. +try: + CELERY_BROKER_URL +except NameError: + CELERY_TASK_ALWAYS_EAGER = True -GETPAID_BACKENDS = ( - 'getpaid.backends.payu', -) -INSTALLED_APPS_CONTRIB = [ - # Should be before django.contrib.admin - 'modeltranslation', +# If SEARCH_INDEX not configured, disable the search. +try: + SOLR +except NameError: + NO_SEARCH_INDEX = True +else: + NO_SEARCH_INDEX = False - # external - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.sites', - 'django.contrib.admin', - 'django.contrib.admindocs', - 'django.contrib.staticfiles', - 'pagination', - 'pipeline', - 'piston', - 'piwik', - 'sorl.thumbnail', - 'kombu.transport.django', - 'honeypot', - 'fnpdjango', - 'getpaid', - 'getpaid.backends.payu', - 'ssify', - 'django_extensions', - # allauth stuff - 'uni_form', - 'allauth', - 'allauth.account', - 'allauth.socialaccount', - 'allauth.socialaccount.providers.openid', - 'allauth.socialaccount.providers.facebook', - # 'allauth.socialaccount.providers.twitter', - ] +try: + SENTRY_DSN +except NameError: + pass +else: + sentry_sdk.init( + dsn=SENTRY_DSN, + integrations=[DjangoIntegration()] + ) -INSTALLED_APPS = INSTALLED_APPS_OUR + INSTALLED_APPS_CONTRIB -# Load localsettings, if they exist +# Dummy secret key for development. try: - from wolnelektury.localsettings import * -except ImportError: - pass + SECRET_KEY +except NameError: + if DEBUG: + SECRET_KEY = 'not-a-secret-key'