3 # Copyright (C) 2012 FinalsClub Foundation
4 """ Production settings and globals. """
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
25 ########## EMAIL CONFIGURATION
26 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
27 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
29 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
30 EMAIL_HOST = environ.get('EMAIL_HOST', 'smtp.gmail.com')
32 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
33 EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', '')
35 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
36 EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', 'your_email@example.com')
38 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
39 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
41 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
42 EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_NAME
44 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
47 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
48 SERVER_EMAIL = EMAIL_HOST_USER
49 ########## END EMAIL CONFIGURATION
52 ########## DATABASE CONFIGURATION
55 'ENGINE': 'django.db.backends.postgresql_psycopg2',
57 'USER': PROD_DB_USERNAME,
58 'PASSWORD': PROD_DB_PASSWORD,
60 'PORT': '', # Set to empty string for default. Not used with sqlite3.
63 ########## END DATABASE CONFIGURATION
66 ########## CACHE CONFIGURATION
67 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
70 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
73 ########## END CACHE CONFIGURATION
76 ########## CELERY CONFIGURATION
77 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
78 BROKER_TRANSPORT = 'amqplib'
80 # Set this number to the amount of allowed concurrent connections on your AMQP
81 # provider, divided by the amount of active workers you have.
83 # For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
84 # they allow 3 concurrent connections. So if you run a single worker, you'd
85 # want this number to be 3. If you had 3 workers running, you'd lower this
86 # number to 1, since 3 workers each maintaining one open connection = 3
89 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
92 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
93 BROKER_CONNECTION_MAX_RETRIES = 0
95 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
96 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
98 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
99 CELERY_RESULT_BACKEND = 'amqp'
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 STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
113 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
114 AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
117 # AWS cache settings, don't change unless you know what you're doing:
118 AWS_EXPIREY = 60 * 60 * 24 * 7
120 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
124 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
125 STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
126 ########## END STORAGE CONFIGURATION
129 ########## COMPRESSION CONFIGURATION
130 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
131 COMPRESS_OFFLINE = True
133 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
134 COMPRESS_STORAGE = DEFAULT_FILE_STORAGE
136 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
137 COMPRESS_CSS_FILTERS += [
138 'compressor.filters.cssmin.CSSMinFilter',
141 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
142 COMPRESS_JS_FILTERS += [
143 'compressor.filters.jsmin.JSMinFilter',
145 ########## END COMPRESSION CONFIGURATION
148 ########## SECRET CONFIGURATION
149 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
150 SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
151 ########## END SECRET CONFIGURATION