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.static_s3 import *
15 from karmaworld.secret.db_settings import PROD_DB_NAME
16 from karmaworld.secret.db_settings import PROD_DB_USERNAME
17 from karmaworld.secret.db_settings import PROD_DB_PASSWORD
20 # Include email is settings are there
21 from karmaworld.secret.email import SMTP_HOST
22 from karmaworld.secret.email import SMTP_USERNAME
23 from karmaworld.secret.email import SMTP_PASSWORD
28 ########## EMAIL CONFIGURATION
30 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
31 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
33 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
34 EMAIL_HOST = environ.get('EMAIL_HOST', SMTP_HOST)
36 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
37 EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', SMTP_PASSWORD)
39 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
40 EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', SMTP_USERNAME)
42 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
43 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
45 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
46 EMAIL_SUBJECT_PREFIX = 'KarmaNotes '
48 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
51 DEFAULT_FROM_EMAIL = 'info@karmanotes.org'
53 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
54 SERVER_EMAIL = EMAIL_HOST_USER
55 ########## END EMAIL CONFIGURATION
58 ########## DATABASE CONFIGURATION
61 'ENGINE': 'django.db.backends.postgresql_psycopg2',
63 'USER': PROD_DB_USERNAME,
64 'PASSWORD': PROD_DB_PASSWORD,
66 'PORT': '', # Set to empty string for default. Not used with sqlite3.
69 ########## END DATABASE CONFIGURATION
72 ########## CACHE CONFIGURATION
73 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
76 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
79 ########## END CACHE CONFIGURATION
82 ########## CELERY CONFIGURATION
83 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
84 BROKER_TRANSPORT = 'amqplib'
86 # Set this number to the amount of allowed concurrent connections on your AMQP
87 # provider, divided by the amount of active workers you have.
89 # For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
90 # they allow 3 concurrent connections. So if you run a single worker, you'd
91 # want this number to be 3. If you had 3 workers running, you'd lower this
92 # number to 1, since 3 workers each maintaining one open connection = 3
95 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
98 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
99 BROKER_CONNECTION_MAX_RETRIES = 0
101 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
102 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
104 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
105 CELERY_RESULT_BACKEND = 'amqp'
108 CELERYBEAT_SCHEDULE = {
109 'tweet-about-notes': {
110 'task': 'tweet_note',
111 'schedule': timedelta(minutes=60),
115 CELERY_TIMEZONE = 'UTC'
117 ########## END CELERY CONFIGURATION
120 ########## STORAGE CONFIGURATION
121 # See: http://django-storages.readthedocs.org/en/latest/index.html
127 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
128 # DEFAULT_FILE_STORAGE comes from karmaworld.secret.static_s3
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
134 # AWS cache settings, don't change unless you know what you're doing:
135 AWS_EXPIREY = 60 * 60 * 24 * 7
137 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
141 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
142 # S3_URL comes from karmaworld.secret.static_s3
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