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.db_settings import PROD_DB_NAME
12 from karmaworld.secret.db_settings import PROD_DB_USERNAME
13 from karmaworld.secret.db_settings import PROD_DB_PASSWORD
16 # Include email is settings are there
17 from karmaworld.secret.email import SMTP_HOST
18 from karmaworld.secret.email import SMTP_USERNAME
19 from karmaworld.secret.email import SMTP_PASSWORD
24 ########## EMAIL CONFIGURATION
26 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
27 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
29 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
30 EMAIL_HOST = environ.get('EMAIL_HOST', SMTP_HOST)
32 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
33 EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', SMTP_PASSWORD)
35 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
36 EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', SMTP_USERNAME)
38 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
39 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
41 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
42 EMAIL_SUBJECT_PREFIX = 'KarmaNotes '
44 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
47 DEFAULT_FROM_EMAIL = 'info@karmanotes.org'
49 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
50 SERVER_EMAIL = EMAIL_HOST_USER
51 ########## END EMAIL CONFIGURATION
54 ########## DATABASE CONFIGURATION
57 'ENGINE': 'django.db.backends.postgresql_psycopg2',
59 'USER': PROD_DB_USERNAME,
60 'PASSWORD': PROD_DB_PASSWORD,
62 'PORT': '', # Set to empty string for default. Not used with sqlite3.
65 ########## END DATABASE CONFIGURATION
68 ########## CACHE CONFIGURATION
69 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
72 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
73 'LOCATION': '127.0.0.1:11211'
76 ########## END CACHE CONFIGURATION
79 ########## CELERY CONFIGURATION
80 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
81 BROKER_TRANSPORT = 'amqplib'
83 # Set this number to the amount of allowed concurrent connections on your AMQP
84 # provider, divided by the amount of active workers you have.
86 # For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
87 # they allow 3 concurrent connections. So if you run a single worker, you'd
88 # want this number to be 3. If you had 3 workers running, you'd lower this
89 # number to 1, since 3 workers each maintaining one open connection = 3
92 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
95 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
96 BROKER_CONNECTION_MAX_RETRIES = 0
98 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
99 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
101 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
102 CELERY_RESULT_BACKEND = 'amqp'
105 CELERYBEAT_SCHEDULE = {
106 'tweet-about-notes': {
107 'task': 'tweet_note',
108 'schedule': timedelta(minutes=60),
112 CELERY_TIMEZONE = 'UTC'
114 ########## END CELERY CONFIGURATION
117 ########## STORAGE CONFIGURATION
118 # See: http://django-storages.readthedocs.org/en/latest/index.html
124 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
125 # DEFAULT_FILE_STORAGE comes from karmaworld.secret.static_s3
126 STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
128 # Put static files in the folder 'static' in our S3 bucket.
129 # This is so they have the same path as they do when served
130 # locally for development.
131 AWS_LOCATION = 'static'
133 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
134 AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
136 # AWS cache settings, don't change unless you know what you're doing:
137 AWS_EXPIREY = 60 * 60 * 24 * 7
139 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
143 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
144 # S3_URL comes from karmaworld.secret.static_s3
145 STATIC_URL = CLOUDFRONT_URL + '/' + AWS_LOCATION + '/'
146 ########## END STORAGE CONFIGURATION
148 ########## SSL FORWARDING CONFIGURATION
149 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
150 ########## END SSL FORWARDING CONFIGURATION
152 ########## COMPRESSION CONFIGURATION
153 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
154 COMPRESS_OFFLINE = True
156 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
157 COMPRESS_STORAGE = DEFAULT_FILE_STORAGE
159 # Make sure that django-compressor serves from CloudFront
160 AWS_S3_CUSTOM_DOMAIN = CLOUDFRONT_DOMAIN
162 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
163 COMPRESS_CSS_FILTERS += [
164 'compressor.filters.datauri.CssDataUriFilter',
165 'compressor.filters.cssmin.CSSMinFilter',
167 COMPRESS_DATA_URI_MAX_SIZE = 5120
169 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
170 COMPRESS_JS_FILTERS += [
171 'compressor.filters.closure.ClosureCompilerFilter',
173 COMPRESS_CLOSURE_COMPILER_BINARY = 'java -jar /usr/bin/compiler.jar'
175 # Links generated by compress are valid for about ten years
176 AWS_QUERYSTRING_EXPIRE = 60 * 60 * 24 * 365 * 10
177 ########## END COMPRESSION CONFIGURATION
180 ########## SECRET CONFIGURATION
181 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
182 SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
183 ########## END SECRET CONFIGURATION