3 # Copyright (C) 2012 FinalsClub Foundation
4 """ Production settings and globals. """
8 from datetime import timedelta
9 from S3 import CallingFormat
13 from karmaworld.secret.db_settings import PROD_DB_NAME
14 from karmaworld.secret.db_settings import PROD_DB_USERNAME
15 from karmaworld.secret.db_settings import PROD_DB_PASSWORD
18 # Include email is settings are there
19 from karmaworld.secret.email import SMTP_HOST
20 from karmaworld.secret.email import SMTP_USERNAME
21 from karmaworld.secret.email import SMTP_PASSWORD
26 ########## EMAIL CONFIGURATION
28 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
29 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
31 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
32 EMAIL_HOST = environ.get('EMAIL_HOST', SMTP_HOST)
34 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
35 EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', SMTP_PASSWORD)
37 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
38 EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', SMTP_USERNAME)
40 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
41 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
43 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
44 EMAIL_SUBJECT_PREFIX = 'KarmaNotes '
46 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
49 DEFAULT_FROM_EMAIL = 'info@karmanotes.org'
51 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
52 SERVER_EMAIL = EMAIL_HOST_USER
53 ########## END EMAIL CONFIGURATION
56 ########## DATABASE CONFIGURATION
59 'ENGINE': 'django.db.backends.postgresql_psycopg2',
61 'USER': PROD_DB_USERNAME,
62 'PASSWORD': PROD_DB_PASSWORD,
64 'PORT': '', # Set to empty string for default. Not used with sqlite3.
67 ########## END DATABASE CONFIGURATION
70 ########## CACHE CONFIGURATION
71 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
74 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
77 ########## END CACHE CONFIGURATION
80 ########## CELERY CONFIGURATION
81 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
82 BROKER_TRANSPORT = 'amqplib'
84 # Set this number to the amount of allowed concurrent connections on your AMQP
85 # provider, divided by the amount of active workers you have.
87 # For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
88 # they allow 3 concurrent connections. So if you run a single worker, you'd
89 # want this number to be 3. If you had 3 workers running, you'd lower this
90 # number to 1, since 3 workers each maintaining one open connection = 3
93 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
96 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
97 BROKER_CONNECTION_MAX_RETRIES = 0
99 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
100 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
102 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
103 CELERY_RESULT_BACKEND = 'amqp'
106 CELERYBEAT_SCHEDULE = {
107 'tweet-about-notes': {
108 'task': 'tweet_note',
109 'schedule': timedelta(minutes=60),
113 CELERY_TIMEZONE = 'UTC'
115 ########## END CELERY CONFIGURATION
118 ########## STORAGE CONFIGURATION
119 # See: http://django-storages.readthedocs.org/en/latest/index.html
125 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
126 # DEFAULT_FILE_STORAGE comes from karmaworld.secret.static_s3
127 STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
129 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
130 AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
132 # AWS cache settings, don't change unless you know what you're doing:
133 AWS_EXPIREY = 60 * 60 * 24 * 7
135 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
139 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
140 # S3_URL comes from karmaworld.secret.static_s3
142 ########## END STORAGE CONFIGURATION
144 ########## SSL FORWARDING CONFIGURATION
145 SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
146 ########## END SSL FORWARDING CONFIGURATION
148 ########## COMPRESSION CONFIGURATION
149 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
150 COMPRESS_OFFLINE = True
152 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
153 COMPRESS_STORAGE = DEFAULT_FILE_STORAGE
155 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
156 COMPRESS_CSS_FILTERS += [
157 'compressor.filters.cssmin.CSSMinFilter',
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',
164 ########## END COMPRESSION CONFIGURATION
167 ########## SECRET CONFIGURATION
168 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
169 SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
170 ########## END SECRET CONFIGURATION