forked from jplusplus/v2.jplusplus.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings_heroku.py
100 lines (83 loc) · 3.15 KB
/
settings_heroku.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- coding: utf-8 -*-
from settings import *
import os
import dj_database_url
# Allow all host headers
ALLOWED_HOSTS = ['*']
DATABASES = {
'default' : dj_database_url.config()
}
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Turn on database level autocommit
# Otherwise db can raise a "current transaction is aborted,
# commands ignored until end of transaction block"
DATABASES['default']['OPTIONS'] = {'autocommit': True,}
# AWS ACCESS
AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = os.getenv('AWS_STORAGE_BUCKET_NAME')
AWS_QUERYSTRING_AUTH = False
AWS_S3_FILE_OVERWRITE = os.getenv('AWS_S3_FILE_OVERWRITE') == "True" and True or False
# Enable debug for minfication
DEBUG = bool(os.getenv('DEBUG', False))
# Configure static files for S3
STATIC_URL = os.getenv('STATIC_URL')
INSTALLED_APPS += ('storages',)
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
# Static storage
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'
# JS/CSS compressor settings
COMPRESS_ENABLED = True
COMPRESS_ROOT = STATIC_ROOT
COMPRESS_URL = STATIC_URL
COMPRESS_STORAGE = STATICFILES_STORAGE
COMPRESS_OFFLINE = False
# Activate CSS minifier
# COMPRESS_CSS_FILTERS = (
# "compressor.filters.cssmin.CSSMinFilter",
# "compressor.filters.template.TemplateFilter",
# )
COMPRESS_JS_FILTERS = (
# "compressor.filters.jsmin.JSMinFilter",
"compressor.filters.template.TemplateFilter",
)
COMPRESS_TEMPLATE_FILTER_CONTEXT = {
'STATIC_URL': STATIC_URL
}
# Activate the cache, for true
os.environ['MEMCACHE_SERVERS'] = os.environ.get('MEMCACHIER_SERVERS', '').replace(',', ';')
os.environ['MEMCACHE_USERNAME'] = os.environ.get('MEMCACHIER_USERNAME', '')
os.environ['MEMCACHE_PASSWORD'] = os.environ.get('MEMCACHIER_PASSWORD', '')
CACHES = {
'default': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'TIMEOUT': 1000,
'BINARY' : True,
'OPTIONS': {
'tcp_nodelay' : True,
'remove_failed': 4
}
}
}
MIDDLEWARE_CLASSES[:0] = ['django.middleware.cache.UpdateCacheMiddleware']
MIDDLEWARE_CLASSES[-1:] = ['django.middleware.cache.FetchFromCacheMiddleware']
CMS_CACHE_DURATIONS = 60
# EMAILS
INSTALLED_APPS += ('djrill',)
MANDRILL_API_KEY = os.getenv('MANDRILL_APIKEY')
SERVER_EMAIL = os.getenv('MANDRILL_USERNAME')
EMAIL_BACKEND = "djrill.mail.backends.djrill.DjrillBackend"
# Sites for DomainNamesMiddleware (in `sources/jplusplus/middleware.py`)
SITES = { # from_url : to_page_reverse_id
"berlin.jplusplus.org" : "paris-berlin",
"paris.jplusplus.org" : "paris-berlin",
"www.berlin.jplusplus.org" : "paris-berlin",
"www.paris.jplusplus.org" : "paris-berlin",
"amsterdam.jplusplus.org" : "amsterdam",
"cologne.jplusplus.org" : "cologne",
"porto.jplusplus.org" : "porto",
"stockholm.jplusplus.org" : "stockholm"
}
# EOF