3 # Copyright (C) 2012 FinalsClub Foundation
4 """ Production settings and globals. """
8 from datetime import timedelta
9 from S3 import CallingFormat
14 from karmaworld.secret.static_s3 import *
16 from karmaworld.secret.db_settings import PROD_DB_NAME
17 from karmaworld.secret.db_settings import PROD_DB_USERNAME
18 from karmaworld.secret.db_settings import PROD_DB_PASSWORD
21 # Include email is settings are there
22 from karmaworld.secret.email import SMTP_HOST
23 from karmaworld.secret.email import SMTP_USERNAME
24 from karmaworld.secret.email import SMTP_PASSWORD
29 ########## EMAIL CONFIGURATION
31 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
32 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
34 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
35 EMAIL_HOST = environ.get('EMAIL_HOST', SMTP_HOST)
37 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
38 EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', SMTP_PASSWORD)
40 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
41 EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', SMTP_USERNAME)
43 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
44 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
46 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
47 EMAIL_SUBJECT_PREFIX = 'KarmaNotes '
49 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
52 DEFAULT_FROM_EMAIL = 'info@karmanotes.org'
54 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
55 SERVER_EMAIL = EMAIL_HOST_USER
56 ########## END EMAIL CONFIGURATION
59 ########## DATABASE CONFIGURATION
62 'ENGINE': 'django.db.backends.postgresql_psycopg2',
64 'USER': PROD_DB_USERNAME,
65 'PASSWORD': PROD_DB_PASSWORD,
67 'PORT': '', # Set to empty string for default. Not used with sqlite3.
70 ########## END DATABASE CONFIGURATION
73 ########## CACHE CONFIGURATION
74 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
77 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
80 ########## END CACHE CONFIGURATION
83 ########## CELERY CONFIGURATION
84 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
85 BROKER_TRANSPORT = 'amqplib'
87 # Set this number to the amount of allowed concurrent connections on your AMQP
88 # provider, divided by the amount of active workers you have.
90 # For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
91 # they allow 3 concurrent connections. So if you run a single worker, you'd
92 # want this number to be 3. If you had 3 workers running, you'd lower this
93 # number to 1, since 3 workers each maintaining one open connection = 3
96 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
99 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
100 BROKER_CONNECTION_MAX_RETRIES = 0
102 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
103 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
105 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
106 CELERY_RESULT_BACKEND = 'amqp'
109 CELERYBEAT_SCHEDULE = {
110 'tweet-about-notes': {
111 'task': 'tweet_note',
112 'schedule': timedelta(minutes=60),
116 CELERY_TIMEZONE = 'UTC'
118 ########## END CELERY CONFIGURATION
121 ########## STORAGE CONFIGURATION
122 # See: http://django-storages.readthedocs.org/en/latest/index.html
128 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
129 STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
131 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
132 AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
134 # Put static files in the folder 'static' in our S3 bucket.
135 # This is so they have the same path as they do when served
136 # locally for development.
137 AWS_LOCATION = 'static'
139 # AWS cache settings, don't change unless you know what you're doing:
140 AWS_EXPIREY = 60 * 60 * 24 * 7
142 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
146 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
147 STATIC_URL = CLOUDFRONT_URL + AWS_LOCATION + '/'
148 ########## END STORAGE CONFIGURATION
151 ########## SSL FORWARDING CONFIGURATION
152 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
153 ########## END SSL FORWARDING CONFIGURATION
156 ########## COMPRESSION CONFIGURATION
157 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
158 COMPRESS_OFFLINE = True
160 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
161 COMPRESS_STORAGE = DEFAULT_FILE_STORAGE
163 # Make sure that django-compressor serves from CloudFront
164 AWS_S3_CUSTOM_DOMAIN = CLOUDFRONT_DOMAIN
166 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
167 COMPRESS_CSS_FILTERS += [
168 'compressor.filters.datauri.CssDataUriFilter',
169 'compressor.filters.cssmin.CSSMinFilter',
171 COMPRESS_DATA_URI_MAX_SIZE = 5120
173 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
174 COMPRESS_JS_FILTERS += [
175 'compressor.filters.closure.ClosureCompilerFilter',
177 COMPRESS_CLOSURE_COMPILER_BINARY = 'java -jar /usr/bin/compiler.jar'
179 # Links generated by compress are valid for about ten years
180 AWS_QUERYSTRING_EXPIRE = 60 * 60 * 24 * 365 * 10
181 ########## END COMPRESSION CONFIGURATION
184 ########## SECRET CONFIGURATION
185 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
186 SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
187 ########## END SECRET CONFIGURATION
189 ########## DEBUG CONFIGURATION
190 # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
193 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
194 TEMPLATE_DEBUG = DEBUG
195 ########## END DEBUG CONFIGURATION
197 ########## TESTING CONFIGURATION
198 # Use django-nose to test our app, see https://github.com/jbalogh/django-nose
199 TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
200 ########## END TESTING CONFIGURATION
202 ########## TOOLBAR CONFIGURATION
203 # See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
206 'template_timings_panel',
211 DEBUG_TOOLBAR_PANELS = (
212 'debug_toolbar.panels.versions.VersionsPanel',
213 'debug_toolbar.panels.timer.TimerPanel',
214 'debug_toolbar.panels.settings.SettingsPanel',
215 'debug_toolbar.panels.headers.HeadersPanel',
216 'debug_toolbar.panels.request.RequestPanel',
217 'debug_toolbar.panels.sql.SQLPanel',
218 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
219 'debug_toolbar.panels.templates.TemplatesPanel',
220 'template_timings_panel.panels.TemplateTimings.TemplateTimings',
221 'debug_toolbar.panels.cache.CachePanel',
222 'debug_toolbar.panels.signals.SignalsPanel',
223 'debug_toolbar.panels.logging.LoggingPanel',
226 # See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
227 INTERNAL_IPS = ('127.0.0.1',)
229 # See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
230 MIDDLEWARE_CLASSES += (
231 'debug_toolbar.middleware.DebugToolbarMiddleware',
233 ########## END TOOLBAR CONFIGURATION
235 ########## PROFILING CONFIGURATION
236 MIDDLEWARE_CLASSES += (
237 'karmaworld.apps.courses.middleware.ProfileMiddleware',
239 ########## END PROFILING CONFIGURATION
241 ########## STATIC CONFIGURATION
242 STATIC_URL = CLOUDFRONT_URL
243 ########## END STATIC CONFIGURATION