A simple ticketing application written in Python/Django
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.

settings.py 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # -*- coding: utf-8 -*-
  2. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  3. import os
  4. import socket
  5. # request.path in templates:
  6. from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP
  7. BASE_DIR = os.path.dirname(os.path.dirname(__file__))
  8. SECRET_KEY = os.environ["DJANGO_SECRET_KEY"]
  9. if socket.gethostname() == os.environ["DJANGO_PRODUCTION_DOMAIN"]:
  10. DEBUG = False
  11. TEMPLATE_DEBUG = False
  12. ALLOWED_HOSTS = ['*']
  13. # SSL/HTTPS
  14. SESSION_COOKIE_SECURE = True
  15. CSRF_COOKIE_SECURE = True
  16. else:
  17. DEBUG = True
  18. TEMPLATE_DEBUG = True
  19. # Application definition
  20. INSTALLED_APPS = (
  21. 'django.contrib.admin',
  22. 'django.contrib.auth',
  23. 'django.contrib.contenttypes',
  24. 'django.contrib.sessions',
  25. 'django.contrib.messages',
  26. 'django.contrib.staticfiles',
  27. 'crispy_forms',
  28. 'main',
  29. )
  30. TEMPLATE_CONTEXT_PROCESSORS = TCP + (
  31. 'django.core.context_processors.request',
  32. )
  33. MIDDLEWARE_CLASSES = (
  34. 'django.contrib.sessions.middleware.SessionMiddleware',
  35. 'django.middleware.common.CommonMiddleware',
  36. 'django.middleware.csrf.CsrfViewMiddleware',
  37. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  38. 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  39. 'django.contrib.messages.middleware.MessageMiddleware',
  40. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  41. )
  42. ROOT_URLCONF = 'tickets.urls'
  43. WSGI_APPLICATION = 'tickets.wsgi.application'
  44. # Database
  45. DATABASES = {
  46. 'default': {
  47. 'ENGINE': 'django.db.backends.sqlite3',
  48. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  49. }
  50. }
  51. # Internationalization
  52. LANGUAGE_CODE = 'en-us'
  53. TIME_ZONE = 'Europe/Berlin'
  54. USE_I18N = True
  55. USE_L10N = True
  56. USE_TZ = True
  57. # Static files (CSS, JavaScript, Images)
  58. STATIC_URL = '/static/'
  59. STATIC_ROOT = os.environ["DJANGO_STATIC_ROOT"]
  60. STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'), )
  61. MEDIA_URL = '/media/'
  62. MEDIA_ROOT = os.environ["DJANGO_MEDIA_ROOT"]
  63. # On login do not redirect to "/accounts/profile/" but "/inbox/"
  64. LOGIN_REDIRECT_URL = "/inbox/"
  65. # in urls.py the function "logout_then_login" is used to log out
  66. # changing the default value from "/accounts/login/" to "/"
  67. LOGIN_URL = "/"
  68. # Django Crispy Forms
  69. CRISPY_TEMPLATE_PACK = 'bootstrap3'
  70. # Define who gets code error notifications.
  71. # When DEBUG=False and a view raises an exception,
  72. # Django will email these people with the full exception information.
  73. ADMINS = ((os.environ["DJANGO_ADMIN_NAME"],
  74. os.environ["DJANGO_ADMIN_EMAIL"]), )
  75. # Specifies who should get broken link notifications when
  76. # BrokenLinkEmailsMiddleware is enabled.
  77. MANAGERS = ((os.environ["DJANGO_ADMIN_NAME"],
  78. os.environ["DJANGO_ADMIN_EMAIL"]), )
  79. # Email delivery to local Postfix-Installation
  80. EMAIL_HOST = os.environ["DJANGO_EMAIL_HOST"]
  81. EMAIL_HOST_USER = os.environ["DJANGO_EMAIL_HOST_USER"]
  82. EMAIL_HOST_PASSWORD = os.environ["DJANGO_EMAIL_HOST_PASSWORD"]
  83. # Logging
  84. LOGGING = {
  85. 'version': 1,
  86. 'disable_existing_loggers': False,
  87. 'formatters': {
  88. 'verbose': {
  89. 'format': "[%(asctime)s] %(levelname)s \
  90. [%(name)s:%(lineno)s] %(message)s",
  91. 'datefmt': "%d/%b/%Y %H:%M:%S"
  92. },
  93. 'simple': {
  94. 'format': '%(levelname)s %(message)s'
  95. },
  96. },
  97. 'handlers': {
  98. 'file': {
  99. 'level': 'INFO',
  100. 'class': 'logging.FileHandler',
  101. 'filename': os.environ["DJANGO_LOG_FILE"],
  102. 'formatter': 'verbose'
  103. },
  104. 'mail_admins': {
  105. 'level': 'ERROR',
  106. 'class': 'django.utils.log.AdminEmailHandler',
  107. }
  108. },
  109. 'loggers': {
  110. 'django': {
  111. 'handlers': ['file'],
  112. 'propagate': True,
  113. 'level': 'INFO',
  114. },
  115. 'django.request': {
  116. 'handlers': ['mail_admins'],
  117. 'level': 'ERROR',
  118. 'propagate': False,
  119. },
  120. 'main': {
  121. 'handlers': ['file'],
  122. 'level': 'INFO',
  123. },
  124. }
  125. }