production.py 3.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Copyright 2014 Budapest University of Technology and Economics (BME IK)
#
# This file is part of CIRCLE Cloud.
#
# CIRCLE is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# CIRCLE is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with CIRCLE.  If not, see <http://www.gnu.org/licenses/>.

18
"""Production settings and globals."""
Bach Dániel committed
19
# flake8: noqa
20 21 22


from os import environ
23
from sys import argv
24

Őry Máté committed
25
from base import *  # noqa
26

27 28
if 'runserver' in argv:
    SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https')
29 30

########## HOST CONFIGURATION
Őry Máté committed
31 32
# See: https://docs.djangoproject.com/en/1.5/releases/1.5/
#      #allowed-hosts-required-in-production
33
ALLOWED_HOSTS = get_env_variable('DJANGO_ALLOWED_HOSTS').split(',')
34 35 36 37 38 39 40 41
########## END HOST CONFIGURATION

########## EMAIL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

try:
    # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
42
    EMAIL_HOST = get_env_variable('EMAIL_HOST')
43
except ImproperlyConfigured:
44
    EMAIL_HOST = 'localhost'
45
else:
Kálmán Viktor committed
46
    # https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
47
    EMAIL_HOST_PASSWORD = get_env_variable('EMAIL_HOST_PASSWORD', '')
48 49

    # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
50
    EMAIL_HOST_USER = get_env_variable('EMAIL_HOST_USER', 'your_email@example.com')
51 52

    # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
53
    EMAIL_PORT = get_env_variable('EMAIL_PORT', 587)
54 55 56 57 58 59 60 61

    # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
    EMAIL_USE_TLS = True

# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_NAME

# See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
62 63
DEFAULT_FROM_EMAIL = get_env_variable('DEFAULT_FROM_EMAIL')
SERVER_EMAIL = get_env_variable('SERVER_EMAIL', DEFAULT_FROM_EMAIL)
64 65 66 67 68
########## END EMAIL CONFIGURATION


########## CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
Bach Dániel committed
69 70 71 72 73 74
from urlparse import urlsplit

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': urlsplit(get_env_variable('CACHE_URI')).netloc,
75
    }
Bach Dániel committed
76
}
77 78 79 80 81
########## END CACHE CONFIGURATION


########## SECRET CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
82
SECRET_KEY = get_env_variable('SECRET_KEY')
83
########## END SECRET CONFIGURATION
84 85 86 87 88 89 90

level = environ.get('LOGLEVEL', 'INFO')
LOGGING['handlers']['syslog']['level'] = level
for i in LOCAL_APPS:
    LOGGING['loggers'][i] = {'handlers': ['syslog'], 'level': level}
LOGGING['loggers']['djangosaml2'] = {'handlers': ['syslog'], 'level': level}
LOGGING['loggers']['django'] = {'handlers': ['syslog'], 'level': level}