Removed AWS var., see secret/static_s3
[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 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
20
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
24
25 ########## EMAIL CONFIGURATION
26 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
27 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
28
29 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
30 EMAIL_HOST = environ.get('EMAIL_HOST', 'smtp.gmail.com')
31
32 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
33 EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', '')
34
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')
37
38 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
39 EMAIL_PORT = environ.get('EMAIL_PORT', 587)
40
41 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
42 EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_NAME
43
44 # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
45 EMAIL_USE_TLS = True
46
47 # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
48 SERVER_EMAIL = EMAIL_HOST_USER
49 ########## END EMAIL CONFIGURATION
50
51
52 ########## DATABASE CONFIGURATION
53 DATABASES = {
54     'default': {
55     'ENGINE': 'django.db.backends.postgresql_psycopg2',
56     'NAME': PROD_DB_NAME,
57     'USER': PROD_DB_USERNAME,
58     'PASSWORD': PROD_DB_PASSWORD,
59     'HOST': 'localhost',
60     'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
61     }
62 }
63 ########## END DATABASE CONFIGURATION
64
65
66 ########## CACHE CONFIGURATION
67 # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
68 CACHES = {
69     'default': {
70         'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
71     }
72 }
73 ########## END CACHE CONFIGURATION
74
75
76 ########## CELERY CONFIGURATION
77 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-transport
78 BROKER_TRANSPORT = 'amqplib'
79
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.
82 #
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
87 # connections total.
88 #
89 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-pool-limit
90 BROKER_POOL_LIMIT = 3
91
92 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-connection-max-retries
93 BROKER_CONNECTION_MAX_RETRIES = 0
94
95 # See: http://docs.celeryproject.org/en/latest/configuration.html#broker-url
96 BROKER_URL = environ.get('RABBITMQ_URL') or environ.get('CLOUDAMQP_URL')
97
98 # See: http://docs.celeryproject.org/en/latest/configuration.html#celery-result-backend
99 CELERY_RESULT_BACKEND = 'amqp'
100 ########## END CELERY CONFIGURATION
101
102
103 ########## STORAGE CONFIGURATION
104 # See: http://django-storages.readthedocs.org/en/latest/index.html
105 INSTALLED_APPS += (
106     'storages',
107 )
108
109 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
110 STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
111
112 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings
113 AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
114
115
116 # AWS cache settings, don't change unless you know what you're doing:
117 AWS_EXPIREY = 60 * 60 * 24 * 7
118 AWS_HEADERS = {
119     'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY,
120         AWS_EXPIREY)
121 }
122
123 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
124 STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
125 ########## END STORAGE CONFIGURATION
126
127
128 ########## COMPRESSION CONFIGURATION
129 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
130 COMPRESS_OFFLINE = True
131
132 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
133 COMPRESS_STORAGE = DEFAULT_FILE_STORAGE
134
135 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
136 COMPRESS_CSS_FILTERS += [
137     'compressor.filters.cssmin.CSSMinFilter',
138 ]
139
140 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
141 COMPRESS_JS_FILTERS += [
142     'compressor.filters.jsmin.JSMinFilter',
143 ]
144 ########## END COMPRESSION CONFIGURATION
145
146
147 ########## SECRET CONFIGURATION
148 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
149 SECRET_KEY = environ.get('SECRET_KEY', SECRET_KEY)
150 ########## END SECRET CONFIGURATION