[Config] add missing import
[mygpo.git] / mygpo / settings.py
blob947d2ab97173563a4bd593eda4a088f9a80b57a4
1 # Django settings for mygpo project.
3 # This file is part of my.gpodder.org.
5 # my.gpodder.org is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or (at your
8 # option) any later version.
10 # my.gpodder.org is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
13 # License for more details.
15 # You should have received a copy of the GNU Affero General Public License
16 # along with my.gpodder.org. If not, see <http://www.gnu.org/licenses/>.
19 import sys
20 import os.path
21 import dj_database_url
23 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
25 # http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#ChangedthewayURLpathsaredetermined
26 FORCE_SCRIPT_NAME=""
28 DEBUG = True
29 TEMPLATE_DEBUG = DEBUG
31 ADMINS = ()
33 MANAGERS = ADMINS
35 DATABASES = {
36 'default': dj_database_url.config(
37 default='postgres://mygpo:mygpo@localhost/mygpo'),
40 COUCHDB_DATABASES = {
41 'mygpo.directory':
42 {'URL': 'http://127.0.0.1:5984/mygpo'},
44 'mygpo.core':
45 {'URL': 'http://127.0.0.1:5984/mygpo'},
47 'mygpo.api':
48 {'URL': 'http://127.0.0.1:5984/mygpo'},
50 'mygpo.users':
51 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
53 'mygpo.share':
54 {'URL': 'http://127.0.0.1:5984/mygpo'},
56 'mygpo.maintenance':
57 {'URL': 'http://127.0.0.1:5984/mygpo'},
59 'mygpo.pubsub':
60 {'URL': 'http://127.0.0.1:5984/mygpo_pubsub'},
62 'mygpo.suggestions':
63 {'URL': 'http://127.0.0.1:5984/mygpo_suggestions'},
65 'django_couchdb_utils_auth':
66 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
68 'django_couchdb_utils_sessions':
69 {'URL': 'http://127.0.0.1:5984/mygpo_sessions'},
71 'django_couchdb_utils_registration':
72 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
74 'mygpo.categories':
75 {'URL': 'http://127.0.0.1:5984/mygpo_categories'},
77 'mygpo.userdata':
78 {'URL': 'http://127.0.0.1:5984/mygpo_userdata'},
81 # Maps design documents to databases. The keys correspond to the directories in
82 # mygpo/couch/, the values are the app labels which are mapped to the actual
83 # databases in COUCHDB_DATABASES. This indirect mapping is used because
84 # COUCHDB_DATABASES is likely to be overwritten in settings_prod.py while
85 # COUCHDB_DDOC_MAPPING is most probably not overwritten.
86 COUCHDB_DDOC_MAPPING = {
87 'general': 'core',
88 'categories': 'categories',
89 'pubsub': 'pubsub',
90 'userdata': 'userdata',
91 'users': 'users',
92 'suggestions': 'suggestions',
95 # Local time zone for this installation. Choices can be found here:
96 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
97 # although not all choices may be available on all operating systems.
98 # If running in a Windows environment this must be set to the same as your
99 # system time zone.
100 TIME_ZONE = 'UTC'
102 # Language code for this installation. All choices can be found here:
103 # http://www.i18nguy.com/unicode/language-identifiers.html
104 LANGUAGE_CODE = 'en-us'
106 SITE_ID = 1
108 # If you set this to False, Django will make some optimizations so as not
109 # to load the internationalization machinery.
110 USE_I18N = True
112 STATIC_ROOT = 'staticfiles'
113 STATIC_URL = '/media/'
115 STATICFILES_DIRS = (
116 os.path.abspath(os.path.join(BASE_DIR, '..', 'htdocs', 'media')),
119 # List of callables that know how to import templates from various sources.
120 TEMPLATE_LOADERS = (
121 'django.template.loaders.app_directories.Loader',
124 MIDDLEWARE_CLASSES = (
125 'django.middleware.cache.UpdateCacheMiddleware',
126 'django.middleware.common.CommonMiddleware',
127 'django.middleware.csrf.CsrfViewMiddleware',
128 'django.middleware.cache.FetchFromCacheMiddleware',
129 'django.contrib.sessions.middleware.SessionMiddleware',
130 'django.contrib.auth.middleware.AuthenticationMiddleware',
131 'django.middleware.locale.LocaleMiddleware',
132 'django.contrib.messages.middleware.MessageMiddleware',
135 ROOT_URLCONF = 'mygpo.urls'
137 TEMPLATE_DIRS = ()
139 INSTALLED_APPS = (
140 'django.contrib.contenttypes', # unused, but tests fail otherwise (?)
141 'django.contrib.messages',
142 'django.contrib.admin',
143 'django.contrib.humanize',
144 'django.contrib.auth',
145 'django.contrib.sessions',
146 'django.contrib.staticfiles',
147 'django_couchdb_utils.couchauth',
148 'django_couchdb_utils.registration',
149 'djcelery',
150 'mygpo.core',
151 'mygpo.podcasts',
152 'mygpo.search',
153 'mygpo.users',
154 'mygpo.api',
155 'mygpo.web',
156 'mygpo.publisher',
157 'mygpo.data',
158 'mygpo.userfeeds',
159 'mygpo.directory',
160 'mygpo.maintenance',
161 'mygpo.share',
162 'mygpo.administration',
163 'mygpo.pubsub',
164 'mygpo.db.couchdb',
167 try:
168 import debug_toolbar
169 INSTALLED_APPS += ('debug_toolbar.apps.DebugToolbarConfig', )
171 except ImportError:
172 print >> sys.stderr, 'Could not load django-debug-toolbar'
175 TEST_EXCLUDE = (
176 'django',
177 'couchdbkit',
180 TEST_RUNNER='mygpo.test.MygpoTestSuiteRunner'
182 ACCOUNT_ACTIVATION_DAYS = 7
184 AUTHENTICATION_BACKENDS = (
185 'django_couchdb_utils.couchauth.backends.CouchDBAuthBackend',
186 'mygpo.web.auth.EmailAuthenticationBackend',
187 'django.contrib.auth.backends.ModelBackend',
190 SESSION_ENGINE = "django_couchdb_utils.sessions.cached_couchdb"
192 # TODO: use (default) JSON serializer for security
193 # this would currently fail as we're (de)serializing datetime objects
194 # https://docs.djangoproject.com/en/1.5/topics/http/sessions/#session-serialization
195 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
198 from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
200 TEMPLATE_CONTEXT_PROCESSORS += (
201 "mygpo.web.google.analytics",
202 "mygpo.web.google.adsense",
204 # make the debug variable available in templates
205 # https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-debug
206 "django.core.context_processors.debug",
208 # required so that the request obj can be accessed from templates.
209 # this is used to direct users to previous page after login
210 'django.core.context_processors.request',
213 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
215 USER_CLASS = 'mygpo.users.models.User'
217 LOGIN_URL = '/login/'
219 CSRF_FAILURE_VIEW='mygpo.web.views.security.csrf_failure'
222 # The following entries should be set in settings_prod.py
223 DEFAULT_FROM_EMAIL = ''
224 SECRET_KEY = ''
225 GOOGLE_ANALYTICS_PROPERTY_ID=''
226 DIRECTORY_EXCLUDED_TAGS = ()
227 FLICKR_API_KEY = ''
229 MAINTENANCE = os.path.exists(os.path.join(BASE_DIR, 'MAINTENANCE'))
232 LOGGING = {
233 'version': 1,
234 'disable_existing_loggers': True,
235 'formatters': {
236 'verbose': {
237 'format': '%(asctime)s %(name)s %(levelname)s %(message)s',
240 'filters': {
241 'require_debug_false': {
242 '()': 'django.utils.log.RequireDebugFalse'
245 'handlers': {
246 'console':{
247 'level': 'DEBUG',
248 'class': 'logging.StreamHandler',
249 'formatter': 'verbose'
251 'mail_admins': {
252 'level': 'ERROR',
253 'filters': ['require_debug_false'],
254 'class': 'django.utils.log.AdminEmailHandler'
257 'loggers': {
258 'django': {
259 'handlers': ['console'],
260 'propagate': True,
261 'level': 'WARN',
263 'mygpo': {
264 'handlers': ['console'],
265 'level': 'INFO',
270 # minimum number of subscribers a podcast must have to be assigned a slug
271 PODCAST_SLUG_SUBSCRIBER_LIMIT = 10
273 # minimum number of subscribers that a podcast needs to "push" one of its
274 # categories to the top
275 MIN_SUBSCRIBERS_CATEGORY=10
277 # maximum number of episode actions that the API processes immediatelly before
278 # returning the response. Larger requests will be handled in background.
279 # Handler can be set to None to disable
280 API_ACTIONS_MAX_NONBG=100
281 API_ACTIONS_BG_HANDLER='mygpo.api.tasks.episode_actions_celery_handler'
284 ADSENSE_CLIENT = ''
285 ADSENSE_SLOT_BOTTOM = ''
287 # enabled access to staff-only areas with ?staff=<STAFF_TOKEN>
288 STAFF_TOKEN = None
290 # Flattr settings -- available after you register your app
291 FLATTR_KEY = ''
292 FLATTR_SECRET = ''
294 # Flattr thing of the webservice. Will be flattr'd when a user sets the "Auto-Flattr gpodder.net" option
295 FLATTR_MYGPO_THING='https://flattr.com/submit/auto?user_id=stefankoegl&url=http://gpodder.net'
297 # The User-Agent string used for outgoing HTTP requests
298 USER_AGENT = 'gpodder.net (+https://github.com/gpodder/mygpo)'
300 # Base URL of the website that is used if the actually used parameters is not
301 # available. Request handlers, for example, can access the requested domain.
302 # Code that runs in background can not do this, and therefore requires a
303 # default value. This should be set to something like 'http://example.com'
304 DEFAULT_BASE_URL = ''
307 ### Celery
309 BROKER_URL='redis://localhost'
310 CELERY_RESULT_BACKEND='redis://localhost'
312 import djcelery
313 djcelery.setup_loader()
315 # a dictionary containing celery settings from
316 # http://docs.celeryproject.org/en/latest/configuration.html
317 CELERY_CONF = dict(
318 CELERY_SEND_TASK_ERROR_EMAILS = True,
319 ADMINS=ADMINS,
320 SERVER_EMAIL = "no-reply@example.com",
324 ### Google API
326 GOOGLE_CLIENT_ID=''
327 GOOGLE_CLIENT_SECRET=''
329 # URL where users of the site can get support
330 SUPPORT_URL=''
333 # Elasticsearch settings
335 ELASTICSEARCH_SERVER = os.getenv('ELASTICSEARCH_SERVER', '127.0.0.1:9200')
336 ELASTICSEARCH_INDEX = os.getenv('ELASTICSEARCH_INDEX', 'mygpo')
337 ELASTICSEARCH_TIMEOUT = float(os.getenv('ELASTICSEARCH_TIMEOUT', '2'))
340 import sys
341 if 'test' in sys.argv:
342 SECRET_KEY = 'test'
345 INTERNAL_IPS = os.getenv('INTERNAL_IPS', '').split()
347 try:
348 from settings_prod import *
349 except ImportError, e:
350 import sys
351 print >> sys.stderr, 'create settings_prod.py with your customized settings'