[Suggestions] move existing code into own app
[mygpo.git] / mygpo / settings.py
blobe9c10de35ce24e8a0c54ccdec8d997358f0f069c
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_categories'},
44 'mygpo.users':
45 {'URL': 'http://127.0.0.1:5984/mygpo_users'},
47 'mygpo.pubsub':
48 {'URL': 'http://127.0.0.1:5984/mygpo_pubsub'},
50 'mygpo.suggestions':
51 {'URL': 'http://127.0.0.1:5984/mygpo_suggestions'},
53 'mygpo.share':
54 {'URL': 'http://127.0.0.1:5984/mygpo_podcastlists'},
56 'mygpo.podcastlists':
57 {'URL': 'http://127.0.0.1:5984/mygpo_podcastlists'},
59 'mygpo.categories':
60 {'URL': 'http://127.0.0.1:5984/mygpo_categories'},
62 'mygpo.userdata':
63 {'URL': 'http://127.0.0.1:5984/mygpo_userdata'},
66 # Maps design documents to databases. The keys correspond to the directories in
67 # mygpo/couch/, the values are the app labels which are mapped to the actual
68 # databases in COUCHDB_DATABASES. This indirect mapping is used because
69 # COUCHDB_DATABASES is likely to be overwritten in settings_prod.py while
70 # COUCHDB_DDOC_MAPPING is most probably not overwritten.
71 COUCHDB_DDOC_MAPPING = {
72 'categories': 'categories',
73 'pubsub': 'pubsub',
74 'userdata': 'userdata',
75 'users': 'users',
76 'suggestions': 'suggestions',
79 # Local time zone for this installation. Choices can be found here:
80 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
81 # although not all choices may be available on all operating systems.
82 # If running in a Windows environment this must be set to the same as your
83 # system time zone.
84 TIME_ZONE = 'UTC'
86 # Language code for this installation. All choices can be found here:
87 # http://www.i18nguy.com/unicode/language-identifiers.html
88 LANGUAGE_CODE = 'en-us'
90 SITE_ID = 1
92 # If you set this to False, Django will make some optimizations so as not
93 # to load the internationalization machinery.
94 USE_I18N = True
96 STATIC_ROOT = 'staticfiles'
97 STATIC_URL = '/media/'
99 STATICFILES_DIRS = (
100 os.path.abspath(os.path.join(BASE_DIR, '..', 'htdocs', 'media')),
103 # List of callables that know how to import templates from various sources.
104 TEMPLATE_LOADERS = (
105 'django.template.loaders.app_directories.Loader',
108 MIDDLEWARE_CLASSES = (
109 'django.middleware.cache.UpdateCacheMiddleware',
110 'django.middleware.common.CommonMiddleware',
111 'django.middleware.csrf.CsrfViewMiddleware',
112 'django.middleware.cache.FetchFromCacheMiddleware',
113 'django.contrib.sessions.middleware.SessionMiddleware',
114 'django.contrib.auth.middleware.AuthenticationMiddleware',
115 'django.middleware.locale.LocaleMiddleware',
116 'django.contrib.messages.middleware.MessageMiddleware',
119 ROOT_URLCONF = 'mygpo.urls'
121 TEMPLATE_DIRS = ()
123 INSTALLED_APPS = (
124 'django.contrib.contenttypes', # unused, but tests fail otherwise (?)
125 'django.contrib.messages',
126 'django.contrib.admin',
127 'django.contrib.humanize',
128 'django.contrib.auth',
129 'django.contrib.sessions',
130 'django.contrib.staticfiles',
131 'djcelery',
132 'mygpo.core',
133 'mygpo.podcasts',
134 'mygpo.chapters',
135 'mygpo.search',
136 'mygpo.users',
137 'mygpo.api',
138 'mygpo.web',
139 'mygpo.publisher',
140 'mygpo.subscriptions',
141 'mygpo.history',
142 'mygpo.favorites',
143 'mygpo.data',
144 'mygpo.userfeeds',
145 'mygpo.suggestions',
146 'mygpo.directory',
147 'mygpo.maintenance',
148 'mygpo.share',
149 'mygpo.administration',
150 'mygpo.pubsub',
151 'mygpo.db.couchdb',
154 try:
155 import debug_toolbar
156 INSTALLED_APPS += ('debug_toolbar', )
158 except ImportError:
159 print >> sys.stderr, 'Could not load django-debug-toolbar'
162 TEST_EXCLUDE = (
163 'django',
164 'couchdbkit',
167 TEST_RUNNER='mygpo.test.MygpoTestSuiteRunner'
169 ACCOUNT_ACTIVATION_DAYS = 7
171 AUTHENTICATION_BACKENDS = (
172 'django.contrib.auth.backends.ModelBackend',
173 'mygpo.web.auth.EmailAuthenticationBackend',
176 SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
178 # TODO: use (default) JSON serializer for security
179 # this would currently fail as we're (de)serializing datetime objects
180 # https://docs.djangoproject.com/en/1.5/topics/http/sessions/#session-serialization
181 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
184 from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
186 TEMPLATE_CONTEXT_PROCESSORS += (
187 "mygpo.web.google.analytics",
188 "mygpo.web.google.adsense",
190 # make the debug variable available in templates
191 # https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-debug
192 "django.core.context_processors.debug",
194 # required so that the request obj can be accessed from templates.
195 # this is used to direct users to previous page after login
196 'django.core.context_processors.request',
199 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
201 USER_CLASS = 'mygpo.users.models.User'
203 LOGIN_URL = '/login/'
205 CSRF_FAILURE_VIEW='mygpo.web.views.security.csrf_failure'
208 # The following entries should be set in settings_prod.py
209 DEFAULT_FROM_EMAIL = ''
210 SECRET_KEY = ''
211 GOOGLE_ANALYTICS_PROPERTY_ID=''
212 DIRECTORY_EXCLUDED_TAGS = ()
213 FLICKR_API_KEY = ''
215 MAINTENANCE = os.path.exists(os.path.join(BASE_DIR, 'MAINTENANCE'))
218 LOGGING = {
219 'version': 1,
220 'disable_existing_loggers': True,
221 'formatters': {
222 'verbose': {
223 'format': '%(asctime)s %(name)s %(levelname)s %(message)s',
226 'filters': {
227 'require_debug_false': {
228 '()': 'django.utils.log.RequireDebugFalse'
231 'handlers': {
232 'console':{
233 'level': 'DEBUG',
234 'class': 'logging.StreamHandler',
235 'formatter': 'verbose'
237 'mail_admins': {
238 'level': 'ERROR',
239 'filters': ['require_debug_false'],
240 'class': 'django.utils.log.AdminEmailHandler'
243 'loggers': {
244 'django': {
245 'handlers': ['console'],
246 'propagate': True,
247 'level': 'WARN',
249 'mygpo': {
250 'handlers': ['console'],
251 'level': 'INFO',
256 # minimum number of subscribers a podcast must have to be assigned a slug
257 PODCAST_SLUG_SUBSCRIBER_LIMIT = 10
259 # minimum number of subscribers that a podcast needs to "push" one of its
260 # categories to the top
261 MIN_SUBSCRIBERS_CATEGORY=10
263 # maximum number of episode actions that the API processes immediatelly before
264 # returning the response. Larger requests will be handled in background.
265 # Handler can be set to None to disable
266 API_ACTIONS_MAX_NONBG=100
267 API_ACTIONS_BG_HANDLER='mygpo.api.tasks.episode_actions_celery_handler'
270 ADSENSE_CLIENT = ''
271 ADSENSE_SLOT_BOTTOM = ''
273 # enabled access to staff-only areas with ?staff=<STAFF_TOKEN>
274 STAFF_TOKEN = None
276 # Flattr settings -- available after you register your app
277 FLATTR_KEY = ''
278 FLATTR_SECRET = ''
280 # Flattr thing of the webservice. Will be flattr'd when a user sets the "Auto-Flattr gpodder.net" option
281 FLATTR_MYGPO_THING='https://flattr.com/submit/auto?user_id=stefankoegl&url=http://gpodder.net'
283 # The User-Agent string used for outgoing HTTP requests
284 USER_AGENT = 'gpodder.net (+https://github.com/gpodder/mygpo)'
286 # Base URL of the website that is used if the actually used parameters is not
287 # available. Request handlers, for example, can access the requested domain.
288 # Code that runs in background can not do this, and therefore requires a
289 # default value. This should be set to something like 'http://example.com'
290 DEFAULT_BASE_URL = ''
293 ### Celery
295 BROKER_URL='redis://localhost'
296 CELERY_RESULT_BACKEND='redis://localhost'
298 CELERY_SEND_TASK_ERROR_EMAILS = True,
299 ADMINS=ADMINS,
300 SERVER_EMAIL = "no-reply@example.com",
303 ### Google API
305 GOOGLE_CLIENT_ID=''
306 GOOGLE_CLIENT_SECRET=''
308 # URL where users of the site can get support
309 SUPPORT_URL=''
312 # Elasticsearch settings
314 ELASTICSEARCH_SERVER = os.getenv('ELASTICSEARCH_SERVER', '127.0.0.1:9200')
315 ELASTICSEARCH_INDEX = os.getenv('ELASTICSEARCH_INDEX', 'mygpo')
316 ELASTICSEARCH_TIMEOUT = float(os.getenv('ELASTICSEARCH_TIMEOUT', '2'))
318 # time for how long an activation is valid; after that, an unactivated user
319 # will be deleted
320 ACTIVATION_VALID_DAYS = int(os.getenv('ACTIVATION_VALID_DAYS', 10))
322 import sys
323 if 'test' in sys.argv:
324 SECRET_KEY = 'test'
327 INTERNAL_IPS = os.getenv('INTERNAL_IPS', '').split()
329 try:
330 from settings_prod import *
331 except ImportError, e:
332 import sys
333 print >> sys.stderr, 'create settings_prod.py with your customized settings'