Development of an internal social media platform with personalised dashboards for students
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 6.9KB

6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. """
  2. Django settings for mysite project.
  3. Generated by 'django-admin startproject' using Django 2.0.6.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/2.0/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/2.0/ref/settings/
  8. """
  9. import os
  10. import re
  11. import socket
  12. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  13. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  14. # Quick-start development settings - unsuitable for production
  15. # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
  16. # SECURITY WARNING: keep the secret key used in production secret!
  17. SECRET_KEY = 'rh2cynsps7=3fb-bmb!+6g(!a(j5i3dq54ps08y2^py8z*49ct'
  18. # SECURITY WARNING: don't run with debug turned on in production!
  19. DEBUG = True
  20. ALLOWED_HOSTS = []
  21. # Development or Production
  22. r = re.search(r'^172.17', socket.gethostbyname(socket.gethostname()))
  23. DEVELOPMENT = (r == None)
  24. # Application definition
  25. INSTALLED_APPS = [
  26. 'django.contrib.admin',
  27. 'django.contrib.auth',
  28. 'django.contrib.contenttypes',
  29. 'django.contrib.sessions',
  30. 'django.contrib.messages',
  31. 'django.contrib.staticfiles',
  32. 'application',
  33. 'taggit',
  34. 'taggit_templatetags2',
  35. 'kombu.transport.django',
  36. 'post_office',
  37. 'hitcount',
  38. ]
  39. MIDDLEWARE = [
  40. 'django.middleware.security.SecurityMiddleware',
  41. 'django.contrib.sessions.middleware.SessionMiddleware',
  42. 'django.middleware.common.CommonMiddleware',
  43. 'django.middleware.csrf.CsrfViewMiddleware',
  44. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  45. 'django.contrib.messages.middleware.MessageMiddleware',
  46. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  47. ]
  48. ROOT_URLCONF = 'mysite.urls'
  49. TEMPLATES = [
  50. {
  51. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  52. 'DIRS': [],
  53. 'APP_DIRS': True,
  54. 'OPTIONS': {
  55. 'context_processors': [
  56. 'django.template.context_processors.debug',
  57. 'django.template.context_processors.request',
  58. 'django.contrib.auth.context_processors.auth',
  59. 'django.contrib.messages.context_processors.messages',
  60. ],
  61. },
  62. },
  63. ]
  64. WSGI_APPLICATION = 'mysite.wsgi.application'
  65. # Database
  66. # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  67. if DEVELOPMENT:
  68. DATABASES = {
  69. 'default': {
  70. 'ENGINE': 'django.db.backends.sqlite3',
  71. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  72. }
  73. }
  74. print(" --- Development sqlite database --- ")
  75. else:
  76. DATABASES = {
  77. 'default': {
  78. 'ENGINE': 'django.db.backends.mysql',
  79. 'NAME': 'django-app',
  80. 'USER': 'django-app',
  81. 'PASSWORD': '*******',
  82. 'HOST': 'mysql',
  83. 'PORT': '3306',
  84. 'OPTIONS': {
  85. 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
  86. },
  87. }
  88. }
  89. # Password validation
  90. # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
  91. AUTH_PASSWORD_VALIDATORS = [
  92. {
  93. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  94. },
  95. {
  96. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  97. },
  98. {
  99. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  100. },
  101. {
  102. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  103. },
  104. ]
  105. # Internationalization
  106. # https://docs.djangoproject.com/en/2.0/topics/i18n/
  107. LANGUAGE_CODE = 'en-us'
  108. TIME_ZONE = 'Europe/Berlin'
  109. USE_I18N = True
  110. USE_L10N = True
  111. USE_TZ = True
  112. # Static files (CSS, JavaScript, Images)
  113. # https://docs.djangoproject.com/en/2.0/howto/static-files/
  114. STATIC_URL = '/static/'
  115. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  116. # Konfiguration des Auth-Systems
  117. LDAP_DOMAIN = 'ADS1'
  118. LDAP_SERVER = 'gso1.ads1.fh-nuernberg.de'
  119. if DEVELOPMENT:
  120. LOGIN_REDIRECT_URL = '/'
  121. LOGOUT_REDIRECT_URL = '/'
  122. LOGIN_URL = "/accounts/login/"
  123. else:
  124. LOGIN_REDIRECT_URL = '/app/'
  125. LOGOUT_REDIRECT_URL = '/app/'
  126. LOGIN_URL = "/app/accounts/login/"
  127. if DEVELOPMENT:
  128. AUTHENTICATION_BACKENDS = [
  129. 'django.contrib.auth.backends.ModelBackend',
  130. ]
  131. print(" --- Development stage --- ")
  132. else:
  133. AUTHENTICATION_BACKENDS = [
  134. 'django.contrib.auth.backends.ModelBackend',
  135. 'mysite.ldap_backend.LdapBackend',
  136. ]
  137. print(" --- Live stage --- ")
  138. AUTH_PROFILE_MODULE = 'application.CustomUser'
  139. #Log Configuration
  140. LOGGING = {
  141. 'version': 1,
  142. 'disable_existing_loggers': True,
  143. 'formatters': {
  144. 'standard': {
  145. 'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
  146. 'datefmt' : "%d/%b/%Y %H:%M:%S"
  147. },
  148. },
  149. 'handlers': {
  150. 'null': {
  151. 'level':'DEBUG',
  152. 'class':'logging.NullHandler',
  153. },
  154. 'logfile': {
  155. 'level':'DEBUG',
  156. 'class':'logging.handlers.RotatingFileHandler',
  157. 'filename': os.path.join(BASE_DIR, 'log.txt'),
  158. 'maxBytes': 50000,
  159. 'backupCount': 2,
  160. 'formatter': 'standard',
  161. },
  162. 'console':{
  163. 'level':'INFO',
  164. 'class':'logging.StreamHandler',
  165. 'formatter': 'standard'
  166. },
  167. },
  168. 'loggers': {
  169. 'django': {
  170. 'handlers':['console'],
  171. 'propagate': True,
  172. 'level':'WARN',
  173. },
  174. 'django.db.backends': {
  175. 'handlers': ['console'],
  176. 'level': 'DEBUG',
  177. 'propagate': False,
  178. },
  179. 'mysite': {
  180. 'handlers': ['console', 'logfile'],
  181. 'level': 'DEBUG',
  182. 'formatter': 'standard'
  183. },
  184. }
  185. }
  186. if DEBUG:
  187. INTERNAL_IPS = ('127.0.0.1', 'localhost',)
  188. MIDDLEWARE += (
  189. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  190. )
  191. INSTALLED_APPS += (
  192. 'debug_toolbar',
  193. )
  194. DEBUG_TOOLBAR_PANELS = [
  195. 'debug_toolbar.panels.versions.VersionsPanel',
  196. 'debug_toolbar.panels.timer.TimerPanel',
  197. 'debug_toolbar.panels.settings.SettingsPanel',
  198. 'debug_toolbar.panels.headers.HeadersPanel',
  199. 'debug_toolbar.panels.request.RequestPanel',
  200. 'debug_toolbar.panels.sql.SQLPanel',
  201. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  202. 'debug_toolbar.panels.templates.TemplatesPanel',
  203. 'debug_toolbar.panels.cache.CachePanel',
  204. 'debug_toolbar.panels.signals.SignalsPanel',
  205. 'debug_toolbar.panels.logging.LoggingPanel',
  206. 'debug_toolbar.panels.redirects.RedirectsPanel',
  207. ]
  208. DEBUG_TOOLBAR_CONFIG = {
  209. 'INTERCEPT_REDIRECTS': False,
  210. }
  211. EMAIL_BACKEND = 'post_office.EmailBackend'
  212. EMAIL_HOST = 'smtp.web.de'
  213. EMAIL_HOST_USER = "esther.kleinhenz@web.de"
  214. EMAIL_PORT = 25 # default smtp port
  215. EMAIL_HOST_PASSWORD = "2mSchneeinMikkeli"
  216. EMAIL_USE_TLS = True
  217. DEFAULT_FROM_EMAIL = 'your.generic.test.email@web.de'