3 # Copyright (C) 2012 FinalsClub Foundation
4 """ Production settings and globals. """
6 from datetime import timedelta
7 from S3 import CallingFormat
11 ########## EMAIL CONFIGURATION
13 # Include email is settings are there
14 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
15 EMAIL_HOST = os.environ['SMTP_HOST']
17 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
18 EMAIL_HOST_USER = os.environ['SMTP_USERNAME']
20 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
21 EMAIL_HOST_PASSWORD = os.environ['SMTP_PASSWORD']
23 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
24 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
26 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
27 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
29 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
30 EMAIL_SUBJECT_PREFIX = 'KarmaNotes '
32 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
35 DEFAULT_FROM_EMAIL = 'info@karmanotes.org'
37 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
38 SERVER_EMAIL = EMAIL_HOST_USER
44 ########## END EMAIL CONFIGURATION
47 ########## CACHE CONFIGURATION
48 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
51 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
52 'LOCATION': '127.0.0.1:11211'
55 ########## END CACHE CONFIGURATION
58 ########## CELERY CONFIGURATION
59 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
60 BROKER_TRANSPORT = 'amqplib'
62 # Set this number to the amount of allowed concurrent connections on your AMQP
63 # provider, divided by the amount of active workers you have.
65 # For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
66 # they allow 3 concurrent connections. So if you run a single worker, you'd
67 # want this number to be 3. If you had 3 workers running, you'd lower this
68 # number to 1, since 3 workers each maintaining one open connection = 3
71 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
74 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
75 BROKER_CONNECTION_MAX_RETRIES = 0
77 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
78 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
80 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
81 CELERY_RESULT_BACKEND = 'amqp'
84 CELERYBEAT_SCHEDULE = {
85 'tweet-about-notes': {
87 'schedule': timedelta(minutes=60),
89 'check-mturk-results': {
90 'task': 'get_extract_keywords_results',
91 'schedule': timedelta(minutes=20),
95 CELERY_TIMEZONE = 'UTC'
97 ########## END CELERY CONFIGURATION
100 ########## STORAGE CONFIGURATION
101 # See: http://django-storages.readthedocs.org/en/latest/index.html
107 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
108 # DEFAULT_FILE_STORAGE comes from karmaworld.secret.static_s3
109 STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
111 # Put static files in the folder 'static' in our S3 bucket.
112 # This is so they have the same path as they do when served
113 # locally for development.
114 AWS_LOCATION = 'static'
116 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
117 AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
119 # AWS cache settings, don't change unless you know what you're doing:
120 AWS_EXPIREY = 60 * 60 * 24 * 7
122 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
126 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
127 # S3_URL comes from karmaworld.secret.static_s3
128 STATIC_URL = '//' + os.environ['CLOUDFRONT_DOMAIN'] + '/' + AWS_LOCATION + '/'
129 ########## END STORAGE CONFIGURATION
131 ########## SSL FORWARDING CONFIGURATION
132 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
134 if os.environ.get('SSL_REDIRECT', False) == 'true':
135 INSTALLED_APPS += ('sslify',)
136 MIDDLEWARE_CLASSES = (
137 'sslify.middleware.SSLifyMiddleware',
138 ) + MIDDLEWARE_CLASSES
139 ########## END SSL FORWARDING CONFIGURATION
141 ########## COMPRESSION CONFIGURATION
142 COMPRESS_ENABLED = True
144 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
145 COMPRESS_OFFLINE = True
147 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
148 COMPRESS_STORAGE = os.environ.get('DEFAULT_FILE_STORAGE')
150 # Make sure that django-compressor serves from CloudFront
151 AWS_S3_CUSTOM_DOMAIN = os.environ.get('CLOUDFRONT_DOMAIN')
153 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
154 COMPRESS_CSS_FILTERS += [
155 'compressor.filters.datauri.CssDataUriFilter',
156 'compressor.filters.cssmin.CSSMinFilter',
158 COMPRESS_DATA_URI_MAX_SIZE = 5120
160 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
161 COMPRESS_JS_FILTERS += [
162 'compressor.filters.jsmin.JSMinFilter',
165 # Links generated by compress are valid for about ten years
166 AWS_QUERYSTRING_EXPIRE = 60 * 60 * 24 * 365 * 10
167 ########## END COMPRESSION CONFIGURATION
169 ########## SECRET CONFIGURATION
170 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
171 SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
172 ########## END SECRET CONFIGURATION