3 # Copyright (C) 2012 FinalsClub Foundation
4 """ Production settings and globals. """
8 from datetime import timedelta
9 from S3 import CallingFormat
14 from karmaworld.secret.static_s3 import DEFAULT_FILE_STORAGE
15 from karmaworld.secret.static_s3 import AWS_ACCESS_KEY_ID
16 from karmaworld.secret.static_s3 import AWS_SECRET_ACCESS_KEY
17 from karmaworld.secret.static_s3 import AWS_STORAGE_BUCKET_NAME
18 from karmaworld.secret.static_s3 import S3_URL
19 from karmaworld.secret.static_s3 import STATIC_URL
21 from karmaworld.secret.db_settings import PROD_DB_NAME
22 from karmaworld.secret.db_settings import PROD_DB_USERNAME
23 from karmaworld.secret.db_settings import PROD_DB_PASSWORD
26 # Include email is settings are there
27 from karmaworld.secret.email import SMTP_HOST
28 from karmaworld.secret.email import SMTP_USERNAME
29 from karmaworld.secret.email import SMTP_PASSWORD
34 ########## EMAIL CONFIGURATION
36 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
37 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
39 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
40 EMAIL_HOST = environ.get('EMAIL_HOST', SMTP_HOST)
42 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
43 EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', SMTP_PASSWORD)
45 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
46 EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', SMTP_USERNAME)
48 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
49 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
51 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
52 EMAIL_SUBJECT_PREFIX = 'KarmaNotes '
54 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
57 DEFAULT_FROM_EMAIL = 'info@karmanotes.org'
59 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
60 SERVER_EMAIL = EMAIL_HOST_USER
61 ########## END EMAIL CONFIGURATION
64 ########## DATABASE CONFIGURATION
67 'ENGINE': 'django.db.backends.postgresql_psycopg2',
69 'USER': PROD_DB_USERNAME,
70 'PASSWORD': PROD_DB_PASSWORD,
72 'PORT': '', # Set to empty string for default. Not used with sqlite3.
75 ########## END DATABASE CONFIGURATION
78 ########## CACHE CONFIGURATION
79 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
82 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
85 ########## END CACHE CONFIGURATION
88 ########## CELERY CONFIGURATION
89 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
90 BROKER_TRANSPORT = 'amqplib'
92 # Set this number to the amount of allowed concurrent connections on your AMQP
93 # provider, divided by the amount of active workers you have.
95 # For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
96 # they allow 3 concurrent connections. So if you run a single worker, you'd
97 # want this number to be 3. If you had 3 workers running, you'd lower this
98 # number to 1, since 3 workers each maintaining one open connection = 3
101 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
102 BROKER_POOL_LIMIT = 3
104 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
105 BROKER_CONNECTION_MAX_RETRIES = 0
107 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
108 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
110 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
111 CELERY_RESULT_BACKEND = 'amqp'
114 CELERYBEAT_SCHEDULE = {
115 'tweet-about-notes': {
116 'task': 'tweet_note',
117 'schedule': timedelta(minutes=60),
121 CELERY_TIMEZONE = 'UTC'
123 ########## END CELERY CONFIGURATION
126 ########## STORAGE CONFIGURATION
127 # See: http://django-storages.readthedocs.org/en/latest/index.html
133 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
134 STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
136 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
137 AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
140 # AWS cache settings, don't change unless you know what you're doing:
141 AWS_EXPIREY = 60 * 60 * 24 * 7
143 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
147 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
148 STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
149 ########## END STORAGE 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 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
160 COMPRESS_CSS_FILTERS += [
161 'compressor.filters.cssmin.CSSMinFilter',
164 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
165 COMPRESS_JS_FILTERS += [
166 'compressor.filters.jsmin.JSMinFilter',
168 ########## END COMPRESSION CONFIGURATION
171 ########## SECRET CONFIGURATION
172 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
173 SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
174 ########## END SECRET CONFIGURATION