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
135 # AWS cache settings, don't change unless you know what you're doing:
136 AWS_EXPIREY = 60 * 60 * 24 * 7
138 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
142 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
144 ########## END STORAGE CONFIGURATION
147 ########## COMPRESSION CONFIGURATION
148 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
149 COMPRESS_OFFLINE = True
151 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
152 COMPRESS_STORAGE = DEFAULT_FILE_STORAGE
154 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
155 COMPRESS_CSS_FILTERS += [
156 'compressor.filters.cssmin.CSSMinFilter',
159 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
160 COMPRESS_JS_FILTERS += [
161 'compressor.filters.jsmin.JSMinFilter',
163 ########## END COMPRESSION CONFIGURATION
166 ########## SECRET CONFIGURATION
167 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
168 SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
169 ########## END SECRET CONFIGURATION
171 ########## DEBUG CONFIGURATION
172 # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
175 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
176 TEMPLATE_DEBUG = DEBUG
177 ########## END DEBUG CONFIGURATION
179 ########## TESTING CONFIGURATION
180 # Use django-nose to test our app, see https://github.com/jbalogh/django-nose
181 TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
182 ########## END TESTING CONFIGURATION
184 ########## TOOLBAR CONFIGURATION
185 # See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
192 # See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
193 INTERNAL_IPS = ('127.0.0.1',)
195 # See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
196 MIDDLEWARE_CLASSES += (
197 'debug_toolbar.middleware.DebugToolbarMiddleware',
200 DEBUG_TOOLBAR_CONFIG = {
201 'INTERCEPT_REDIRECTS': False # Don't interrput our redirects!
203 ########## END TOOLBAR CONFIGURATION