Schule als Staat Projekt Web, Dokumente, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.4KB

  1. """
  2. Django settings for sas_web project.
  3. Generated by 'django-admin startproject' using Django 1.8.7.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/1.8/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/1.8/ref/settings/
  8. """
  9. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  10. import os
  11. deployed = '1' == os.environ.get('DJANGO_DEPLOY', '0')
  12. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  13. # Quick-start development settings - unsuitable for production
  14. # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
  15. # SECURITY WARNING: keep the secret key used in production secret!
  16. SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY',
  17. 'dnwe1fairy&@7=qoe7(w0bahnt9(&%zn8bph5&-r$1*s2$d2@h')
  18. # SECURITY WARNING: don't run with debug turned on in production!
  19. debug = os.environ.get('DJANGO_DEBUG', None)
  20. if debug:
  21. DEBUG = False if debug == '0' else True
  22. else:
  23. DEBUG = True
  24. allowed = os.environ.get('DJANGO_ALLOWED_HOST', None)
  25. if allowed is not None:
  26. ALLOWED_HOSTS = allowed.split(",")
  27. else:
  28. ALLOWED_HOSTS = []
  29. # Define media paths e.g. for image storage
  30. MEDIA_URL = '/media/'
  31. MEDIA_ROOT = os.environ.get('DJANGO_MEDIA_ROOT',
  32. os.path.join((os.path.join(BASE_DIR, os.pardir)), "media"))
  33. # x forward
  34. USE_X_FORWARDED_HOST = True
  35. # Application definition
  36. INSTALLED_APPS = (
  37. 'news',
  38. 'captcha',
  39. 'datenbank',
  40. 'meingoethopia',
  41. 'startpage',
  42. 'django.contrib.admin',
  43. 'django.contrib.auth',
  44. 'django.contrib.contenttypes',
  45. 'django.contrib.sessions',
  46. 'django.contrib.messages',
  47. 'django.contrib.staticfiles',
  48. )
  49. MIDDLEWARE_CLASSES = (
  50. 'sas_web.block_ip.BlockedIpMiddleware',
  51. 'django.contrib.sessions.middleware.SessionMiddleware',
  52. 'django.middleware.common.CommonMiddleware',
  53. 'django.middleware.csrf.CsrfViewMiddleware',
  54. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  55. 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  56. 'django.contrib.messages.middleware.MessageMiddleware',
  57. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  58. 'django.middleware.security.SecurityMiddleware',
  59. )
  60. ROOT_URLCONF = 'sas_web.urls'
  61. TEMPLATES = [
  62. {
  63. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  64. 'DIRS': [os.path.join(BASE_DIR, 'templates')],
  65. 'APP_DIRS': True,
  66. 'OPTIONS': {
  67. 'context_processors': [
  68. 'django.template.context_processors.debug',
  69. 'django.template.context_processors.request',
  70. 'django.contrib.auth.context_processors.auth',
  71. 'django.contrib.messages.context_processors.messages',
  72. 'sas_web.contexts.appname',
  73. ],
  74. },
  75. },
  76. ]
  77. WSGI_APPLICATION = 'sas_web.wsgi.application'
  78. # Database
  79. # https://docs.djangoproject.com/en/1.8/ref/settings/#databases
  80. DATABASES = {
  81. 'default': {
  82. 'ENGINE': 'django.db.backends.mysql',
  83. 'NAME': os.environ.get('DJANGO_DATABASE_NAME', 'sas_db'),
  84. 'OPTIONS': {
  85. 'read_default_file': os.environ.get('DJANGO_DATABASE_CONFIG',
  86. os.path.join(BASE_DIR, 'my.cnf'))
  87. }
  88. }
  89. }
  90. # Internationalization
  91. # https://docs.djangoproject.com/en/1.8/topics/i18n/
  92. LANGUAGE_CODE = 'de-de'
  93. TIME_ZONE = 'Europe/Berlin'
  94. USE_I18N = True
  95. USE_L10N = True
  96. USE_TZ = True
  97. # Static files (CSS, JavaScript, Images)
  98. # https://docs.djangoproject.com/en/1.8/howto/static-files/
  99. STATIC_URL = '/static/'
  100. STATICFILES_DIRS = [
  101. os.path.join(BASE_DIR, "static")
  102. ]
  103. STATIC_ROOT = os.environ.get('DJANGO_STATIC_ROOT',
  104. os.path.join((os.path.join(BASE_DIR, os.pardir)), "static"))
  105. # Email setup
  106. EMAIL_HOST = os.environ.get('EMAIL_HOST', 'localhost')
  107. EMAIL_PORT = 587 if deployed else 25
  108. EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', '')
  109. EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD', '')
  110. EMAIL_USE_TLS = True if deployed else False
  111. EMAIL_ARBEITSMINISTERIUM = os.environ.get('EMAIL_ARBEITSMINISTERIUM', '')
  112. EMAIL_ARBEITSMINISTERIUM_USER = os.environ.get('EMAIL_ARBEITSMINISTERIUM', '')
  113. EMAIL_ARBEITSMINISTERIUM_PASSWORD = os.environ.get('EMAIL_ARBEITSMINISTERIUM_PASSWORD', '')
  114. EMAIL_INFO = os.environ.get('EMAIL_INFO', '')
  115. EMAIL_INFO_USER = os.environ.get('EMAIL_INFO', '')
  116. EMAIL_INFO_PASSWORD = os.environ.get('EMAIL_INFO_PASSWORD', '')