3 # Copyright (C) 2012 FinalsClub Foundation
4 """ Production settings and globals. """
6 from datetime import timedelta
7 from S3 import CallingFormat
12 # Include email is settings are there
13 SMTP_HOST = os.environ['SMTP_HOST']
14 SMTP_USERNAME = os.environ['SMTP_USERNAME']
15 SMTP_PASSWORD = os.environ['SMTP_PASSWORD']
20 ########## EMAIL CONFIGURATION
22 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
23 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
25 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
26 EMAIL_HOST = environ.get('EMAIL_HOST', SMTP_HOST)
28 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
29 EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', SMTP_PASSWORD)
31 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
32 EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', SMTP_USERNAME)
34 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
35 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
37 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
38 EMAIL_SUBJECT_PREFIX = 'KarmaNotes '
40 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
43 DEFAULT_FROM_EMAIL = 'info@karmanotes.org'
45 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
46 SERVER_EMAIL = EMAIL_HOST_USER
47 ########## END EMAIL CONFIGURATION
50 ########## CACHE CONFIGURATION
51 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
54 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
55 'LOCATION': '127.0.0.1:11211'
58 ########## END CACHE CONFIGURATION
61 ########## CELERY CONFIGURATION
62 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
63 BROKER_TRANSPORT = 'amqplib'
65 # Set this number to the amount of allowed concurrent connections on your AMQP
66 # provider, divided by the amount of active workers you have.
68 # For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
69 # they allow 3 concurrent connections. So if you run a single worker, you'd
70 # want this number to be 3. If you had 3 workers running, you'd lower this
71 # number to 1, since 3 workers each maintaining one open connection = 3
74 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
77 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
78 BROKER_CONNECTION_MAX_RETRIES = 0
80 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
81 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
83 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
84 CELERY_RESULT_BACKEND = 'amqp'
87 CELERYBEAT_SCHEDULE = {
88 'tweet-about-notes': {
90 'schedule': timedelta(minutes=60),
92 'check-mturk-results': {
93 'task': 'get_extract_keywords_results',
94 'schedule': timedelta(minutes=20),
98 CELERY_TIMEZONE = 'UTC'
100 ########## END CELERY CONFIGURATION
103 ########## STORAGE CONFIGURATION
104 # See: http://django-storages.readthedocs.org/en/latest/index.html
110 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
111 # DEFAULT_FILE_STORAGE comes from karmaworld.secret.static_s3
112 STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
114 # Put static files in the folder 'static' in our S3 bucket.
115 # This is so they have the same path as they do when served
116 # locally for development.
117 AWS_LOCATION = 'static'
119 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
120 AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
122 # AWS cache settings, don't change unless you know what you're doing:
123 AWS_EXPIREY = 60 * 60 * 24 * 7
125 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
129 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
130 # S3_URL comes from karmaworld.secret.static_s3
131 STATIC_URL = os.environ.get('CLOUDFRONT_URL') + AWS_LOCATION + '/'
132 ########## END STORAGE CONFIGURATION
134 ########## SSL FORWARDING CONFIGURATION
135 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
136 ########## END SSL FORWARDING CONFIGURATION
138 ########## COMPRESSION CONFIGURATION
139 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
140 COMPRESS_OFFLINE = True
142 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
143 COMPRESS_STORAGE = os.environ.get('DEFAULT_FILE_STORAGE')
145 # Make sure that django-compressor serves from CloudFront
146 AWS_S3_CUSTOM_DOMAIN = os.environ.get('CLOUDFRONT_DOMAIN')
148 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
149 COMPRESS_CSS_FILTERS += [
150 'compressor.filters.datauri.CssDataUriFilter',
151 'compressor.filters.cssmin.CSSMinFilter',
153 COMPRESS_DATA_URI_MAX_SIZE = 5120
155 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
156 COMPRESS_JS_FILTERS += [
157 'compressor.filters.closure.ClosureCompilerFilter',
159 COMPRESS_CLOSURE_COMPILER_BINARY = 'java -jar /usr/bin/compiler.jar'
161 # Links generated by compress are valid for about ten years
162 AWS_QUERYSTRING_EXPIRE = 60 * 60 * 24 * 365 * 10
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