3 # Copyright (C) 2012 FinalsClub Foundation
4 """ Production settings and globals. """
6 from datetime import timedelta
7 from S3 import CallingFormat
11 from karmaworld.secret.static_s3 import *
14 # Include email is settings are there
15 from karmaworld.secret.email import SMTP_HOST
16 from karmaworld.secret.email import SMTP_USERNAME
17 from karmaworld.secret.email import SMTP_PASSWORD
22 ########## EMAIL CONFIGURATION
24 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
25 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
27 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
28 EMAIL_HOST = environ.get('EMAIL_HOST', SMTP_HOST)
30 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
31 EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', SMTP_PASSWORD)
33 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
34 EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', SMTP_USERNAME)
36 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
37 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
39 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
40 EMAIL_SUBJECT_PREFIX = 'KarmaNotes '
42 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
45 DEFAULT_FROM_EMAIL = 'info@karmanotes.org'
47 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
48 SERVER_EMAIL = EMAIL_HOST_USER
49 ########## END EMAIL CONFIGURATION
52 ########## DATABASE CONFIGURATION
55 'ENGINE': 'django.db.backends.postgresql_psycopg2',
57 'USER': PROD_DB_USERNAME,
58 'PASSWORD': PROD_DB_PASSWORD,
60 'PORT': '', # Set to empty string for default. Not used with sqlite3.
63 ########## END DATABASE CONFIGURATION
66 ########## CACHE CONFIGURATION
67 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
70 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
73 ########## END CACHE CONFIGURATION
76 ########## CELERY CONFIGURATION
77 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
78 BROKER_TRANSPORT = 'amqplib'
80 # Set this number to the amount of allowed concurrent connections on your AMQP
81 # provider, divided by the amount of active workers you have.
83 # For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
84 # they allow 3 concurrent connections. So if you run a single worker, you'd
85 # want this number to be 3. If you had 3 workers running, you'd lower this
86 # number to 1, since 3 workers each maintaining one open connection = 3
89 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
92 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
93 BROKER_CONNECTION_MAX_RETRIES = 0
95 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
96 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
98 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
99 CELERY_RESULT_BACKEND = 'amqp'
102 CELERYBEAT_SCHEDULE = {
103 'tweet-about-notes': {
104 'task': 'tweet_note',
105 'schedule': timedelta(minutes=60),
109 CELERY_TIMEZONE = 'UTC'
111 ########## END CELERY CONFIGURATION
114 ########## STORAGE CONFIGURATION
115 # See: http://django-storages.readthedocs.org/en/latest/index.html
121 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
122 STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
124 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
125 AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
127 # Put static files in the folder 'static' in our S3 bucket.
128 # This is so they have the same path as they do when served
129 # locally for development.
130 AWS_LOCATION = 'static'
132 # AWS cache settings, don't change unless you know what you're doing:
133 AWS_EXPIREY = 60 * 60 * 24 * 7
135 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
139 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
140 STATIC_URL = CLOUDFRONT_URL + AWS_LOCATION + '/'
141 ########## END STORAGE CONFIGURATION
144 ########## SSL FORWARDING CONFIGURATION
145 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
146 ########## END SSL FORWARDING CONFIGURATION
149 ########## COMPRESSION CONFIGURATION
150 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
151 COMPRESS_OFFLINE = True
153 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
154 COMPRESS_STORAGE = DEFAULT_FILE_STORAGE
156 # Make sure that django-compressor serves from CloudFront
157 AWS_S3_CUSTOM_DOMAIN = CLOUDFRONT_DOMAIN
159 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
160 COMPRESS_CSS_FILTERS += [
161 'compressor.filters.datauri.CssDataUriFilter',
162 'compressor.filters.cssmin.CSSMinFilter',
164 COMPRESS_DATA_URI_MAX_SIZE = 5120
166 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
167 COMPRESS_JS_FILTERS += [
168 'compressor.filters.closure.ClosureCompilerFilter',
170 COMPRESS_CLOSURE_COMPILER_BINARY = 'java -jar /usr/bin/compiler.jar'
172 # Links generated by compress are valid for about ten years
173 AWS_QUERYSTRING_EXPIRE = 60 * 60 * 24 * 365 * 10
174 ########## END COMPRESSION CONFIGURATION
177 ########## SECRET CONFIGURATION
178 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
179 SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
180 ########## END SECRET CONFIGURATION
182 ########## DEBUG CONFIGURATION
183 # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
186 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
187 TEMPLATE_DEBUG = DEBUG
188 ########## END DEBUG CONFIGURATION
190 ########## TESTING CONFIGURATION
191 # Use django-nose to test our app, see https://github.com/jbalogh/django-nose
192 TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
193 ########## END TESTING CONFIGURATION
195 ########## TOOLBAR CONFIGURATION
196 # See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
203 DEBUG_TOOLBAR_PANELS = (
204 'debug_toolbar.panels.versions.VersionsPanel',
205 'debug_toolbar.panels.timer.TimerPanel',
206 'debug_toolbar.panels.settings.SettingsPanel',
207 'debug_toolbar.panels.headers.HeadersPanel',
208 'debug_toolbar.panels.request.RequestPanel',
209 'debug_toolbar.panels.sql.SQLPanel',
210 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
211 'debug_toolbar.panels.templates.TemplatesPanel',
212 'debug_toolbar.panels.cache.CachePanel',
213 'debug_toolbar.panels.signals.SignalsPanel',
214 'debug_toolbar.panels.logging.LoggingPanel',
217 # See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
218 INTERNAL_IPS = ('127.0.0.1',)
220 # See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
221 MIDDLEWARE_CLASSES += (
222 'debug_toolbar.middleware.DebugToolbarMiddleware',
224 ########## END TOOLBAR CONFIGURATION
226 ########## PROFILING CONFIGURATION
227 MIDDLEWARE_CLASSES += (
228 'karmaworld.apps.courses.middleware.ProfileMiddleware',
230 ########## END PROFILING CONFIGURATION
232 ########## STATIC CONFIGURATION
233 STATIC_URL = CLOUDFRONT_URL
234 ########## END STATIC CONFIGURATION