Merge branch 'master' of https://github.com/FinalsClub/karmaworld into pylibmc
[oweals/karmaworld.git] / karmaworld / settings / prod.py
1 #!/usr/bin/env python
2 # -*- coding:utf8 -*-
3 # Copyright (C) 2012  FinalsClub Foundation
4 """ Production settings and globals. """
5
6
7 from os import environ
8
9 from S3 import CallingFormat
10
11 from common import *
12
13
14 ########## EMAIL CONFIGURATION
15 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
16 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
17
18 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
19 EMAIL_HOST = environ.get('EMAIL_HOST', 'smtp.gmail.com')
20
21 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
22 EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', '')
23
24 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
25 EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', 'your_email@example.com')
26
27 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
28 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
29
30 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
31 EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_NAME
32
33 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
34 EMAIL_USE_TLS = True
35
36 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
37 SERVER_EMAIL = EMAIL_HOST_USER
38 ########## END EMAIL CONFIGURATION
39
40
41 ########## DATABASE CONFIGURATION
42 DATABASES = {
43     'default': {
44     'ENGINE': 'django.db.backends.postgresql_psycopg2',
45     'NAME': PROD_DB_NAME,
46     'USER': PROD_DB_USERNAME,
47     'PASSWORD': PROD_DB_PASSWORD,
48     'HOST': 'localhost',
49     'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
50     }
51 }
52 ########## END DATABASE CONFIGURATION
53
54
55 ########## CACHE CONFIGURATION
56 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
57 CACHES = {
58     'default': {
59         'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
60     }
61 }
62 ########## END CACHE CONFIGURATION
63
64
65 ########## CELERY CONFIGURATION
66 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
67 BROKER_TRANSPORT = 'amqplib'
68
69 # Set this number to the amount of allowed concurrent connections on your AMQP
70 # provider, divided by the amount of active workers you have.
71 #
72 # For example, if you have the 'Little Lemur' CloudAMQP plan (their free tier),
73 # they allow 3 concurrent connections. So if you run a single worker, you'd
74 # want this number to be 3. If you had 3 workers running, you'd lower this
75 # number to 1, since 3 workers each maintaining one open connection = 3
76 # connections total.
77 #
78 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
79 BROKER_POOL_LIMIT = 3
80
81 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
82 BROKER_CONNECTION_MAX_RETRIES = 0
83
84 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
85 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
86
87 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
88 CELERY_RESULT_BACKEND = 'amqp'
89 ########## END CELERY CONFIGURATION
90
91
92 ########## STORAGE CONFIGURATION
93 # See: http://django-storages.readthedocs.org/en/latest/index.html
94 INSTALLED_APPS += (
95     'storages',
96 )
97
98 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
99 STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
100
101 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
102 AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
103
104 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
105 AWS_ACCESS_KEY_ID = environ.get('AWS_ACCESS_KEY_ID', '')
106 AWS_SECRET_ACCESS_KEY = environ.get('AWS_SECRET_ACCESS_KEY', '')
107 AWS_STORAGE_BUCKET_NAME = environ.get('AWS_STORAGE_BUCKET_NAME', '')
108 AWS_AUTO_CREATE_BUCKET = True
109 AWS_QUERYSTRING_AUTH = False
110
111 # AWS cache settings, don't change unless you know what you're doing:
112 AWS_EXPIREY = 60 * 60 * 24 * 7
113 AWS_HEADERS = {
114     'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
115         AWS_EXPIREY)
116 }
117
118 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
119 STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
120 ########## END STORAGE CONFIGURATION
121
122
123 ########## COMPRESSION CONFIGURATION
124 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
125 COMPRESS_OFFLINE = True
126
127 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
128 COMPRESS_STORAGE = DEFAULT_FILE_STORAGE
129
130 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
131 COMPRESS_CSS_FILTERS += [
132     'compressor.filters.cssmin.CSSMinFilter',
133 ]
134
135 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
136 COMPRESS_JS_FILTERS += [
137     'compressor.filters.jsmin.JSMinFilter',
138 ]
139 ########## END COMPRESSION CONFIGURATION
140
141
142 ########## SECRET CONFIGURATION
143 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
144 SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
145 ########## END SECRET CONFIGURATION