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 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. ]
  34. MIDDLEWARE = [
  35. 'django.middleware.security.SecurityMiddleware',
  36. 'django.contrib.sessions.middleware.SessionMiddleware',
  37. 'django.middleware.common.CommonMiddleware',
  38. 'django.middleware.csrf.CsrfViewMiddleware',
  39. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  40. 'django.contrib.messages.middleware.MessageMiddleware',
  41. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  42. ]
  43. ROOT_URLCONF = 'mysite.urls'
  44. TEMPLATES = [
  45. {
  46. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  47. 'DIRS': [],
  48. 'APP_DIRS': True,
  49. 'OPTIONS': {
  50. 'context_processors': [
  51. 'django.template.context_processors.debug',
  52. 'django.template.context_processors.request',
  53. 'django.contrib.auth.context_processors.auth',
  54. 'django.contrib.messages.context_processors.messages',
  55. ],
  56. },
  57. },
  58. ]
  59. WSGI_APPLICATION = 'mysite.wsgi.application'
  60. # Database
  61. # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  62. if DEVELOPMENT:
  63. DATABASES = {
  64. 'default': {
  65. 'ENGINE': 'django.db.backends.sqlite3',
  66. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  67. }
  68. }
  69. else:
  70. DATABASES = {
  71. 'default': {
  72. 'ENGINE': 'django.db.backends.mysql',
  73. 'NAME': 'django-app',
  74. 'USER': 'django-app',
  75. 'PASSWORD': '*******',
  76. 'HOST': 'mysql',
  77. 'PORT': '3306',
  78. 'OPTIONS': {
  79. 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
  80. },
  81. }
  82. }
  83. # Password validation
  84. # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
  85. AUTH_PASSWORD_VALIDATORS = [
  86. {
  87. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  88. },
  89. {
  90. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  91. },
  92. {
  93. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  94. },
  95. {
  96. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  97. },
  98. ]
  99. # Internationalization
  100. # https://docs.djangoproject.com/en/2.0/topics/i18n/
  101. LANGUAGE_CODE = 'en-us'
  102. TIME_ZONE = 'Europe/Berlin'
  103. USE_I18N = True
  104. USE_L10N = True
  105. USE_TZ = True
  106. # Static files (CSS, JavaScript, Images)
  107. # https://docs.djangoproject.com/en/2.0/howto/static-files/
  108. STATIC_URL = '/static/'
  109. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  110. # Konfiguration des Auth-Systems
  111. LDAP_DOMAIN = 'ADS1'
  112. LDAP_SERVER = 'gso1.ads1.fh-nuernberg.de'
  113. if DEVELOPMENT:
  114. LOGIN_REDIRECT_URL = '/'
  115. LOGOUT_REDIRECT_URL = '/'
  116. LOGIN_URL = "/accounts/login/"
  117. else:
  118. LOGIN_REDIRECT_URL = '/app/'
  119. LOGOUT_REDIRECT_URL = '/app/'
  120. LOGIN_URL = "/app/accounts/login/"
  121. if DEVELOPMENT:
  122. AUTHENTICATION_BACKENDS = [
  123. 'django.contrib.auth.backends.ModelBackend',
  124. ]
  125. else:
  126. AUTHENTICATION_BACKENDS = [
  127. 'django.contrib.auth.backends.ModelBackend',
  128. 'medinf.ldap_backend.LdapBackend',
  129. ]