[PodcastLists] fixes various bugs, adds tests
[mygpo.git] / mygpo / settings.py
blobbff3bf6cad1996be9d8ee974af8f5afb01cab7f9
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 # Local time zone for this installation. Choices can be found here:
41 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
42 # although not all choices may be available on all operating systems.
43 # If running in a Windows environment this must be set to the same as your
44 # system time zone.
45 TIME_ZONE = 'UTC'
47 # Language code for this installation. All choices can be found here:
48 # http://www.i18nguy.com/unicode/language-identifiers.html
49 LANGUAGE_CODE = 'en-us'
51 SITE_ID = 1
53 # If you set this to False, Django will make some optimizations so as not
54 # to load the internationalization machinery.
55 USE_I18N = True
57 STATIC_ROOT = 'staticfiles'
58 STATIC_URL = '/media/'
60 STATICFILES_DIRS = (
61 os.path.abspath(os.path.join(BASE_DIR, '..', 'htdocs', 'media')),
64 # List of callables that know how to import templates from various sources.
65 TEMPLATE_LOADERS = (
66 'django.template.loaders.app_directories.Loader',
69 MIDDLEWARE_CLASSES = (
70 'django.middleware.cache.UpdateCacheMiddleware',
71 'django.middleware.common.CommonMiddleware',
72 'django.middleware.csrf.CsrfViewMiddleware',
73 'django.middleware.cache.FetchFromCacheMiddleware',
74 'django.contrib.sessions.middleware.SessionMiddleware',
75 'django.contrib.auth.middleware.AuthenticationMiddleware',
76 'django.middleware.locale.LocaleMiddleware',
77 'django.contrib.messages.middleware.MessageMiddleware',
80 ROOT_URLCONF = 'mygpo.urls'
82 TEMPLATE_DIRS = ()
84 INSTALLED_APPS = (
85 'django.contrib.contenttypes',
86 'django.contrib.messages',
87 'django.contrib.admin',
88 'django.contrib.humanize',
89 'django.contrib.auth',
90 'django.contrib.sessions',
91 'django.contrib.staticfiles',
92 'djcelery',
93 'mygpo.core',
94 'mygpo.podcasts',
95 'mygpo.chapters',
96 'mygpo.search',
97 'mygpo.users',
98 'mygpo.api',
99 'mygpo.web',
100 'mygpo.publisher',
101 'mygpo.subscriptions',
102 'mygpo.history',
103 'mygpo.favorites',
104 'mygpo.data',
105 'mygpo.userfeeds',
106 'mygpo.suggestions',
107 'mygpo.directory',
108 'mygpo.categories',
109 'mygpo.episodestates',
110 'mygpo.maintenance',
111 'mygpo.share',
112 'mygpo.administration',
113 'mygpo.pubsub',
114 'mygpo.podcastlists',
115 'mygpo.votes',
118 try:
119 import debug_toolbar
120 INSTALLED_APPS += ('debug_toolbar', )
122 except ImportError:
123 print >> sys.stderr, 'Could not load django-debug-toolbar'
125 TEST_RUNNER = 'django.test.runner.DiscoverRunner'
127 ACCOUNT_ACTIVATION_DAYS = 7
129 AUTHENTICATION_BACKENDS = (
130 'django.contrib.auth.backends.ModelBackend',
131 'mygpo.web.auth.EmailAuthenticationBackend',
134 SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
136 # TODO: use (default) JSON serializer for security
137 # this would currently fail as we're (de)serializing datetime objects
138 # https://docs.djangoproject.com/en/1.5/topics/http/sessions/#session-serialization
139 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
142 from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
144 TEMPLATE_CONTEXT_PROCESSORS += (
145 "mygpo.web.google.analytics",
146 "mygpo.web.google.adsense",
148 # make the debug variable available in templates
149 # https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-debug
150 "django.core.context_processors.debug",
152 # required so that the request obj can be accessed from templates.
153 # this is used to direct users to previous page after login
154 'django.core.context_processors.request',
157 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
159 USER_CLASS = 'mygpo.users.models.User'
161 LOGIN_URL = '/login/'
163 CSRF_FAILURE_VIEW='mygpo.web.views.security.csrf_failure'
166 # The following entries should be set in settings_prod.py
167 DEFAULT_FROM_EMAIL = ''
168 SECRET_KEY = os.getenv('SECRET_KEY', '')
169 GOOGLE_ANALYTICS_PROPERTY_ID=''
170 DIRECTORY_EXCLUDED_TAGS = ()
171 FLICKR_API_KEY = ''
173 MAINTENANCE = os.path.exists(os.path.join(BASE_DIR, 'MAINTENANCE'))
176 LOGGING = {
177 'version': 1,
178 'disable_existing_loggers': True,
179 'formatters': {
180 'verbose': {
181 'format': '%(asctime)s %(name)s %(levelname)s %(message)s',
184 'filters': {
185 'require_debug_false': {
186 '()': 'django.utils.log.RequireDebugFalse'
189 'handlers': {
190 'console':{
191 'level': 'DEBUG',
192 'class': 'logging.StreamHandler',
193 'formatter': 'verbose'
195 'mail_admins': {
196 'level': 'ERROR',
197 'filters': ['require_debug_false'],
198 'class': 'django.utils.log.AdminEmailHandler'
201 'loggers': {
202 'django': {
203 'handlers': ['console'],
204 'propagate': True,
205 'level': 'WARN',
207 'mygpo': {
208 'handlers': ['console'],
209 'level': 'INFO',
211 'celery': {
212 'handlers': ['console'],
213 'level': 'DEBUG',
218 # minimum number of subscribers a podcast must have to be assigned a slug
219 PODCAST_SLUG_SUBSCRIBER_LIMIT = 10
221 # minimum number of subscribers that a podcast needs to "push" one of its
222 # categories to the top
223 MIN_SUBSCRIBERS_CATEGORY=10
225 # maximum number of episode actions that the API processes immediatelly before
226 # returning the response. Larger requests will be handled in background.
227 # Handler can be set to None to disable
228 API_ACTIONS_MAX_NONBG=100
229 API_ACTIONS_BG_HANDLER='mygpo.api.tasks.episode_actions_celery_handler'
232 ADSENSE_CLIENT = ''
233 ADSENSE_SLOT_BOTTOM = ''
235 # enabled access to staff-only areas with ?staff=<STAFF_TOKEN>
236 STAFF_TOKEN = None
238 # Flattr settings -- available after you register your app
239 FLATTR_KEY = ''
240 FLATTR_SECRET = ''
242 # Flattr thing of the webservice. Will be flattr'd when a user sets the "Auto-Flattr gpodder.net" option
243 FLATTR_MYGPO_THING='https://flattr.com/submit/auto?user_id=stefankoegl&url=http://gpodder.net'
245 # The User-Agent string used for outgoing HTTP requests
246 USER_AGENT = 'gpodder.net (+https://github.com/gpodder/mygpo)'
248 # Base URL of the website that is used if the actually used parameters is not
249 # available. Request handlers, for example, can access the requested domain.
250 # Code that runs in background can not do this, and therefore requires a
251 # default value. This should be set to something like 'http://example.com'
252 DEFAULT_BASE_URL = ''
255 ### Celery
257 BROKER_URL='redis://localhost'
258 CELERY_RESULT_BACKEND='redis://localhost'
260 #CELERY_SEND_TASK_ERROR_EMAILS = True
261 SERVER_EMAIL = "no-reply@example.com"
264 ### Google API
266 GOOGLE_CLIENT_ID=''
267 GOOGLE_CLIENT_SECRET=''
269 # URL where users of the site can get support
270 SUPPORT_URL=''
273 # Elasticsearch settings
275 ELASTICSEARCH_SERVER = os.getenv('ELASTICSEARCH_SERVER', '127.0.0.1:9200')
276 ELASTICSEARCH_INDEX = os.getenv('ELASTICSEARCH_INDEX', 'mygpo')
277 ELASTICSEARCH_TIMEOUT = float(os.getenv('ELASTICSEARCH_TIMEOUT', '2'))
279 # time for how long an activation is valid; after that, an unactivated user
280 # will be deleted
281 ACTIVATION_VALID_DAYS = int(os.getenv('ACTIVATION_VALID_DAYS', 10))
283 import sys
284 if 'test' in sys.argv:
285 SECRET_KEY = 'test'
288 INTERNAL_IPS = os.getenv('INTERNAL_IPS', '').split()
290 try:
291 from settings_prod import *
292 except ImportError, e:
293 import sys
294 print >> sys.stderr, 'create settings_prod.py with your customized settings'