[Migration] move podcastlists to their own db
[mygpo.git] / mygpo / settings.py
blob5f3aff7f3571ea0ac1ca97bf6160bb7790763e78
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 'mygpo.podcastlists':
66 {'URL': 'http://127.0.0.1:5984/mygpo_podcastlists'},
68 'django_couchdb_utils_auth':
69 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
71 'django_couchdb_utils_sessions':
72 {'URL': 'http://127.0.0.1:5984/mygpo_sessions'},
74 'django_couchdb_utils_registration':
75 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
77 'mygpo.categories':
78 {'URL': 'http://127.0.0.1:5984/mygpo_categories'},
80 'mygpo.userdata':
81 {'URL': 'http://127.0.0.1:5984/mygpo_userdata'},
84 # Maps design documents to databases. The keys correspond to the directories in
85 # mygpo/couch/, the values are the app labels which are mapped to the actual
86 # databases in COUCHDB_DATABASES. This indirect mapping is used because
87 # COUCHDB_DATABASES is likely to be overwritten in settings_prod.py while
88 # COUCHDB_DDOC_MAPPING is most probably not overwritten.
89 COUCHDB_DDOC_MAPPING = {
90 'general': 'core',
91 'categories': 'categories',
92 'pubsub': 'pubsub',
93 'userdata': 'userdata',
94 'users': 'users',
95 'suggestions': 'suggestions',
98 # Local time zone for this installation. Choices can be found here:
99 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
100 # although not all choices may be available on all operating systems.
101 # If running in a Windows environment this must be set to the same as your
102 # system time zone.
103 TIME_ZONE = 'UTC'
105 # Language code for this installation. All choices can be found here:
106 # http://www.i18nguy.com/unicode/language-identifiers.html
107 LANGUAGE_CODE = 'en-us'
109 SITE_ID = 1
111 # If you set this to False, Django will make some optimizations so as not
112 # to load the internationalization machinery.
113 USE_I18N = True
115 STATIC_ROOT = 'staticfiles'
116 STATIC_URL = '/media/'
118 STATICFILES_DIRS = (
119 os.path.abspath(os.path.join(BASE_DIR, '..', 'htdocs', 'media')),
122 # List of callables that know how to import templates from various sources.
123 TEMPLATE_LOADERS = (
124 'django.template.loaders.app_directories.Loader',
127 MIDDLEWARE_CLASSES = (
128 'django.middleware.cache.UpdateCacheMiddleware',
129 'django.middleware.common.CommonMiddleware',
130 'django.middleware.csrf.CsrfViewMiddleware',
131 'django.middleware.cache.FetchFromCacheMiddleware',
132 'django.contrib.sessions.middleware.SessionMiddleware',
133 'django.contrib.auth.middleware.AuthenticationMiddleware',
134 'django.middleware.locale.LocaleMiddleware',
135 'django.contrib.messages.middleware.MessageMiddleware',
138 ROOT_URLCONF = 'mygpo.urls'
140 TEMPLATE_DIRS = ()
142 INSTALLED_APPS = (
143 'django.contrib.contenttypes', # unused, but tests fail otherwise (?)
144 'django.contrib.messages',
145 'django.contrib.admin',
146 'django.contrib.humanize',
147 'django.contrib.auth',
148 'django.contrib.sessions',
149 'django.contrib.staticfiles',
150 'django_couchdb_utils.couchauth',
151 'django_couchdb_utils.registration',
152 'djcelery',
153 'mygpo.core',
154 'mygpo.podcasts',
155 'mygpo.search',
156 'mygpo.users',
157 'mygpo.api',
158 'mygpo.web',
159 'mygpo.publisher',
160 'mygpo.data',
161 'mygpo.userfeeds',
162 'mygpo.directory',
163 'mygpo.maintenance',
164 'mygpo.share',
165 'mygpo.administration',
166 'mygpo.pubsub',
167 'mygpo.db.couchdb',
170 try:
171 import debug_toolbar
172 INSTALLED_APPS += ('debug_toolbar.apps.DebugToolbarConfig', )
174 except ImportError:
175 print >> sys.stderr, 'Could not load django-debug-toolbar'
178 TEST_EXCLUDE = (
179 'django',
180 'couchdbkit',
183 TEST_RUNNER='mygpo.test.MygpoTestSuiteRunner'
185 ACCOUNT_ACTIVATION_DAYS = 7
187 AUTHENTICATION_BACKENDS = (
188 'django_couchdb_utils.couchauth.backends.CouchDBAuthBackend',
189 'mygpo.web.auth.EmailAuthenticationBackend',
190 'django.contrib.auth.backends.ModelBackend',
193 SESSION_ENGINE = "django_couchdb_utils.sessions.cached_couchdb"
195 # TODO: use (default) JSON serializer for security
196 # this would currently fail as we're (de)serializing datetime objects
197 # https://docs.djangoproject.com/en/1.5/topics/http/sessions/#session-serialization
198 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
201 from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
203 TEMPLATE_CONTEXT_PROCESSORS += (
204 "mygpo.web.google.analytics",
205 "mygpo.web.google.adsense",
207 # make the debug variable available in templates
208 # https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-debug
209 "django.core.context_processors.debug",
211 # required so that the request obj can be accessed from templates.
212 # this is used to direct users to previous page after login
213 'django.core.context_processors.request',
216 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
218 USER_CLASS = 'mygpo.users.models.User'
220 LOGIN_URL = '/login/'
222 CSRF_FAILURE_VIEW='mygpo.web.views.security.csrf_failure'
225 # The following entries should be set in settings_prod.py
226 DEFAULT_FROM_EMAIL = ''
227 SECRET_KEY = ''
228 GOOGLE_ANALYTICS_PROPERTY_ID=''
229 DIRECTORY_EXCLUDED_TAGS = ()
230 FLICKR_API_KEY = ''
232 MAINTENANCE = os.path.exists(os.path.join(BASE_DIR, 'MAINTENANCE'))
235 LOGGING = {
236 'version': 1,
237 'disable_existing_loggers': True,
238 'formatters': {
239 'verbose': {
240 'format': '%(asctime)s %(name)s %(levelname)s %(message)s',
243 'filters': {
244 'require_debug_false': {
245 '()': 'django.utils.log.RequireDebugFalse'
248 'handlers': {
249 'console':{
250 'level': 'DEBUG',
251 'class': 'logging.StreamHandler',
252 'formatter': 'verbose'
254 'mail_admins': {
255 'level': 'ERROR',
256 'filters': ['require_debug_false'],
257 'class': 'django.utils.log.AdminEmailHandler'
260 'loggers': {
261 'django': {
262 'handlers': ['console'],
263 'propagate': True,
264 'level': 'WARN',
266 'mygpo': {
267 'handlers': ['console'],
268 'level': 'INFO',
273 # minimum number of subscribers a podcast must have to be assigned a slug
274 PODCAST_SLUG_SUBSCRIBER_LIMIT = 10
276 # minimum number of subscribers that a podcast needs to "push" one of its
277 # categories to the top
278 MIN_SUBSCRIBERS_CATEGORY=10
280 # maximum number of episode actions that the API processes immediatelly before
281 # returning the response. Larger requests will be handled in background.
282 # Handler can be set to None to disable
283 API_ACTIONS_MAX_NONBG=100
284 API_ACTIONS_BG_HANDLER='mygpo.api.tasks.episode_actions_celery_handler'
287 ADSENSE_CLIENT = ''
288 ADSENSE_SLOT_BOTTOM = ''
290 # enabled access to staff-only areas with ?staff=<STAFF_TOKEN>
291 STAFF_TOKEN = None
293 # Flattr settings -- available after you register your app
294 FLATTR_KEY = ''
295 FLATTR_SECRET = ''
297 # Flattr thing of the webservice. Will be flattr'd when a user sets the "Auto-Flattr gpodder.net" option
298 FLATTR_MYGPO_THING='https://flattr.com/submit/auto?user_id=stefankoegl&url=http://gpodder.net'
300 # The User-Agent string used for outgoing HTTP requests
301 USER_AGENT = 'gpodder.net (+https://github.com/gpodder/mygpo)'
303 # Base URL of the website that is used if the actually used parameters is not
304 # available. Request handlers, for example, can access the requested domain.
305 # Code that runs in background can not do this, and therefore requires a
306 # default value. This should be set to something like 'http://example.com'
307 DEFAULT_BASE_URL = ''
310 ### Celery
312 BROKER_URL='redis://localhost'
313 CELERY_RESULT_BACKEND='redis://localhost'
315 import djcelery
316 djcelery.setup_loader()
318 # a dictionary containing celery settings from
319 # http://docs.celeryproject.org/en/latest/configuration.html
320 CELERY_CONF = dict(
321 CELERY_SEND_TASK_ERROR_EMAILS = True,
322 ADMINS=ADMINS,
323 SERVER_EMAIL = "no-reply@example.com",
327 ### Google API
329 GOOGLE_CLIENT_ID=''
330 GOOGLE_CLIENT_SECRET=''
332 # URL where users of the site can get support
333 SUPPORT_URL=''
336 # Elasticsearch settings
338 ELASTICSEARCH_SERVER = os.getenv('ELASTICSEARCH_SERVER', '127.0.0.1:9200')
339 ELASTICSEARCH_INDEX = os.getenv('ELASTICSEARCH_INDEX', 'mygpo')
340 ELASTICSEARCH_TIMEOUT = float(os.getenv('ELASTICSEARCH_TIMEOUT', '2'))
343 import sys
344 if 'test' in sys.argv:
345 SECRET_KEY = 'test'
348 INTERNAL_IPS = os.getenv('INTERNAL_IPS', '').split()
350 try:
351 from settings_prod import *
352 except ImportError, e:
353 import sys
354 print >> sys.stderr, 'create settings_prod.py with your customized settings'